Forms sometimes open as tabbed documents and sometimes not - ms-access

I am working in Access 365 and am struggling with forms that sometimes launch as pop-ups and sometimes launch as tabbed documents.
My database Options-->Datasheet-->Document Window Options are set to Tabbed Documents and checked for Display Document Tabs.
My form Properties are set to Popup = No and Modal = No.
I'm going around in circles trying to figure out a pattern as to why sometimes the same form will open as a tab but other times open as a pop-up.
Here is one example: I have a navigation form that shows a list of customers, and double-clicking on the customer name fires off a simple macro that does the following:
DoCmd.OpenForm "frmCustomerInfo", _
WhereCondition:="[ID] = " & Me.[ID], _
DataMode:=acFormEdit, _
WindowMode:=acDialog
However, when I launch the CustomerInfo form from the navigation form, it is opening as a pop-up.
Can anyone help provide some insight? Is there another setting that I'm missing?
Thanks in advance.

Related

Microsoft Access calculated control breaks in Navigation Form

I have a form in Microsoft Access 2013 that uses the following formula in a calculated text box to summarize outcomes:
=DCount("[Log]![Outcome]","[Log]","[Log]![Outcome] ='Good' AND [Log]![User]= [Forms]![User Summary]![UserName]")
In effect, the formula looks in the "Log" Table and gives me the total count where the "Outcome" is "Good" for the User that matches the current user selected in the "User Summary" form.
The formula works great when I access the "User Summary" form directly. However, if I embed the "User Summary" form into a navigation form, the formula returns an error. The error stops and normal behavior resumes if I open the original "User Summary" form in the background.
Any ideas how to make this work in a Navigation form without having to open the User Summary form in the background? I eventually will be handing the interface to multiple people, and I don't want them to have to open various forms in the background just to get the navigation to work.
Try this:
=DCount("[Log]![Outcome]","[Log]","[Log]![Outcome] ='Good' AND [Log]![User]='" & Me.MySubformName!UserName & "'")
A bit simplified:
=DCount("Outcome","Log","Outcome='Good' AND User='" & Me.MySubformName!UserName & "'")
Where MySubformName is not the name of the form but the name of the control in the main form that contains the subform.
Depending on where your control is you may need to do something like Forms.MyMainForm.MySubForm!UserName. Basically when your form is embedded in another form you have to call it by starting from the main form and work downwards.
The inbuilt Navigation form uses a subform to display your forms.
Unfortunately they also unload the form from the subform container when it isn't selected, so that form isn't actually present in the background. Whilst this is a clever technique to improve perceived performance, it isn't without it's issues if you don't know it's doing it.
This is why most developers make their own Navigation forms.

Microsoft Access 2013 Button Issue

I have kind of a two part issue (they may be related, I'm not sure). I've never worked with Microsoft Access 2013 before (or any Access version really), and using a "for dummies" type book I'm trying to build a front end interface to link to a SQL database. To do this I'm using the navigation form, regular forms, and then the tables themselves in subforms within that. The forms that hold the subforms are also where I'm placing my buttons. My intentions with these buttons are to use them to filter the table to specific records. I have one doing that successfully (via the main navigation form) but then I have the problem of all the other buttons not working at all, or calling the same text box that that one calls.
This is the code to the working button:
I added the stop Macros actions in an effort to keep the same box from popping up when I pressed another button that houses the macro with a show all records action. Because of issues I also added a stop macro action before the show all records actions on this button (I would do a picture but I'm only allowed two links per the site rules).
This one I found when I added the stop action to the macro before the show all action it stopped the box from popping up, but it also doesn't work to show me all the records. Without the stop action, it acts exactly like the Search Mill ID Button.
The second part of my issues is that my third button currently does show me all records despite it being me trying to use it as a search feature to have a box pop up and the user enter in all or part of a company name to filter the records.
That code looks like this:
I am pretty sure there are a few things wrong with the code on this button in general, but have been having trouble finding any resources of people who are having the same problems as me (or perhaps the issue is so basic most users just automatically know what to do). I've been relying on youtube videos and an access for dummies book to try to build this stuff, but realize that I'm a little beyond my skills; however, I still have to get it done for my job so I'm persevering through.
I appreciate any tips/suggestions to help!
One approach would be to set the OnClick event of your button to use VBA code (Event Procedure), and get the Mill_Id from an Input Box. Macros are much more limiting than VBA and you cannot reasonably use error handling. You can then set the RecordSource property of the form when the button is clicked. The buttons OnClick event would be something like this:
Private Sub Command0_Click()
s = InputBox("What is the Mill ID?", "Mill ID", "")
Me.RecordSource = "SELECT * FROM MyTableWithMillData WHERE Mill_ID = '" & s & "'"
End Sub
Or if the button is on a parent form, and you're trying to change the subform, use this:
Private Sub Command0_Click()
s = InputBox("What is the Mill ID?", "Mill ID", "")
Me!subformcontrolname.Form.RecordSource = "SELECT * FROM MyTableWithMillData WHERE Mill_ID = '" & s & "'"
End Sub

Access Navigation Control BrowseTo "The command or action 'BrowseTo' isn't available now. Error 2046

Using MSAccess 2016 64 bit with SQL SERVER Express 2014 backend.
I have a form "frm_Navigation" with a subform control "NavigationSubform" and a Navigation control.
There are several forms for different tasks within the database that are loaded into the NavigationSubform by clicking the buttons on the Navigation control.
Some of the navigation is managed from the Navigation Control, but some is initiated from a subform. When the user clicks a button on the control, it appears "pressed", but when I navigate using the following, I am not able to make the button appear pressed without changing the colour on the button.
This is how I am currently navigation from a subform:
Form_frm_Navigation.NavigationSubform.SourceObject = "frm_SearchResults"
Form_frm_Navigation.lbl_Header.Caption = "Search Results"
I have read the following posts, but sadly I'm not able to accomplish what I am trying to do
https://blogs.office.com/2010/02/23/access-2010-browseto-docmd-and-macro-action/
http://www.utteraccess.com/forum/index.php?showtopic=1986422
navigating to a different tab in navigation subform
Opening subform within navigations (ELI5)
Main form: frm_Navigation
subform Control on Main from: NavigationSubform
Subform containing code: frm_Search
Form I am trying to open: frm_SearchResults
DoCmd.BrowseTo acBrowseToForm, "frm_SearchResults", "frm_Navigation.NavigationSubform"
Error '2046': The command or action "BrowseTo" isn't available now.
Expected outcome: frm_Search is loaded in the subform control of frm_Navigation by default. After the user enters criteria in the search fields on the frm_Search and clicks btn_search the results are populated into a table, then the frm_SearchResults is opened to display the found records.
I have tried setting the focus to the Main form first, clearing the source of the NavigationSubform, setting the source of the NavigationSubform to the form I am trying to open (I read somewhere that the form must be open) and several permutations of the BrowseTo arguments.
EDIT 2016-07-04 16:04 GMT
It works now as long as the Navigation form is first closed, then reopened. It is not elegant, but the Navigation button now lights up to indicate which is "selected".
Excerpt of code in "frm_Search", a subform of "frm_Navigation" occupying the "frm_Navigation.NavigationSubform"
Is there a way to achieve this without closing the navigation form?
DoCmd.Close
DoCmd.OpenForm "frm_Navigation"
DoCmd.BrowseTo acBrowseToForm, "frm_SearchResults", "frm_Navigation.NavigationSubform"

form submitting with onLoad input values instead of user inputted values when automated with VBA

Main Issue: When I submit a form using vba, the form's inputs' values change unexpectedly. I'm looking to see if there's an issue I don't know of with document.forms().submit in vba that might be related?
Code first, explanation follows:
htmlwindow.Document.getElementById("ReportNum_DropDownList").selectedIndex = 15
htmlwindow.Document.getElementById("ToMMYY_TextBox").Value = QtrMo & "/" & QtrYr
htmlwindow.Document.getElementById("FromMMYY_TextBox").Value = QtrMo_min2 & "/" & QtrYr
htmlwindow.Document.getElementById("ReportCols_DropDownList").selectedIndex = 2
htmlwindow.Document.getElementById("__EVENTTARGET").Value = "Display"
htmlwindow.Document.forms("Form1").submit
Using vba in excel I open IE, navigate to a login page and login, then arrive at "Reports" page which has "Form1", which has several elements.
When the Reports page loads, all of Form1's inputs have pre-loaded values from the last time I used the website. For instance input "FromMMYY_TextBox" is a text box that already reads "08/15" when the Reports page loads. I have several lines of code that update the inputs, including "FromMMYY_TextBox". Then I submit the form, and when it submits, it ignores the new values in the inputs and uses the pre-loaded values that populated the inputs upon originally loading the page. So if I made "FromMMYY_TextBox".Value = "09/15", it submits as "08/15" for some reason.
There is no "on_submit" in the element. I also tried to clear history/cookies/form submissions/passwords/etc from IE and do this, but when the Reports page loads, the inputs are still pre-populated. When I use ".click" on Form1's submit button, I have a more "intense" problem so that's ruled out as an option I think.
Is there anything strange about document.forms().submit that might cause this? Or should I try to see if I'm tripping some kind of validation code? I'm lost on what could cause this.
Edit: When I use ".click" on the Form's submit button, the form submits with the correct input values, but it will not display in the browser like it should. Instead it attempts to download the table as an excel file, which I do not want.
Edit2: I turned off auto-complete in IE and it did not help.

Forms calling reports in access

Step1: I open an Access form when the software opens. It acts like a switchboard manager where the user can open other forms and reports. (Popup = yes, modal = no)
Step2: Click to open a "Master Form" which also has other options. (ditto) So the original VB code called this form to be open and is still "running" in the background.
Step 3: Click to open a report based on the record selected.
So now there's 2 forms open and 1 report. User cannot toggle between them, must close one to get to the other (necessary).
On the open report, I would like to modify the rightclick commandbar. However, "Close" doesn't work because Access now shows Form1 and Form2 above as gray and Access is locked. I would like to be able to right-click to do a number of things including Close, Change to Design View, etc. But if I'm locked out like this, none of these will work.
I searched on...
1. Ending the background vba that's running - no luck
2. Setting focus on the active screen name - no luck
3. Setting focus on a control on the Form2 above - no luck
4. Tried all kinds of CommandBar things, no luck (ID choice vs. manual OnAction) and many more
I'd be happy to attach what I'm doing but it's pretty big, although I could probably cut out the sections that this applies too...
I've been searching for about 16 hours now... Anyone???
Thanks so much.
Popup = Yes in Access means two things:
The form or report stays above all other forms and reports that have Popup = No and above Access’ application window.
The form or report is not bound to the area of Access' application window and can be drawn outside of it.
You have two options:
Set Popup = No for the two forms. In this case they will be tied to the application window area.
Set Popup = Yes for the report as well, so that it can stand in front of the two forms.