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

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"

Related

Hiding the Navigation Pane cause a problem when exiting the database

I just found something strange with MS-Access 2016. I have a database with 2 forms: one hidden, one for a menu. The autoexec will open the hidden form and that one will open the menu form.
I unchecked some options, under Current Database e.g. [Display Navigation Pane] and [Allow Full Menus].
I have an exit button/command on the menu form. On Click, it calls DoCmd.Quit. But before exiting, I am getting an MS-Access window asking for the parameter that is normally when the form open, not when it is closing.
After doing a lot of testing and I mean a lot, I realised that the problem is related to the fact that I am disabling the [Display Navigation Pane]. If I keep the navigation pane, but instead I unchecked all Object Type, then everything works correctly.
So, my question is why disabling the navigation pane can create something like that and is there a way to fix it?
Yes, my solution works, but I don’t like it since users can open and close the navigation pane using the shutter bar; nothing shows but it is still distracting and users can call for support.
The problem is not related to the fact that the first form is hidden, but because it is open. If I add a DoCmd.Close acForm, “F_Parameter” before my DoCmd.Quit then it works.
It is easy to reproduce the problem:
Create a new database
Create two forms:
F_Parameter
F_Menu
Create a Macro named Autoexec:
OpenForm
Form Name: F_Parameter
Window Mode: Hidden
In form F_Parameter create an event On Load
Private Sub Form_Load()
DoCmd.OpenForm “F_Menu”
End Sub
In form F_Menu create a Button named Btn_Exit with an event On Click
Private Sub Btn_Exit_Click()
DoCmd.Quit
End Sub
In form F_Menu create an event On Load
Private Sub Form_Load()
MsgBox “Hello”
End Sub
go File, Options, Current Database and
uncheck Display Navigation Pane and
uncheck Allow Full Menus
Save, exit and open the database:
You will get a “Hello” because the F_Menu form open, now click on the exit and you will get another “Hello”. This second one should not be there because the form should be closing not opening.
I was able to reproduce the issue described. I don't think it has anything to do with the Navigation Pane.
This is happening because while the DoCmd.Quit event is occurring, the hidden F_Parameter form is becoming "unhidden" in order for Access to close it. This causes the F_Parameter Form.Load event to run, which is essentially opening F_Menu, thus causing the Form.Load event on F_Menu to run.
I was able to solve this by first explicitly closing F_Parameter, then quitting:
DoCmd.Close ObjectType:=acForm, ObjectName:="F_Parameter", Save:=acSaveNo
DoCmd.Quit

Access: change subform based on button press

Im pretty new to programming for MS Access and Visual basic. I'm trying to create a form that will change what the subform is based on a toggled option press.
I have attached pictures of the simple form I'm trying to do and gotten some code off tutorial sites that have shown an example of how to do it but I'm not sure if I should have the subforms pre-created or make the button load the form when clicked.
Option Compare Database
Private Sub Option0_Click()
End Sub
Private Sub Toggle11_GotFocus()
Form1!Testform1.SetFocus
End Sub
Private Sub Toggle12_GotFocus()
Form1!Testform2.SetFocus
End Sub
I know this code isn't all that's needed but I can't seem to find a good place to start to find out what needs to be done with this.
Newer versions of Access seem to hide subform tabs when you open a form, but there is a tab stop property for the childforms. I set the property for that to yes and then for one of the child forms to set the tab index to 0 and the other to 1. You can toggle between the forms using Ctrl Tab when you do this. If the Child Form tabs are not visible when you open the main form, Ctrl Tab will also make them visible allowing you to click on the tabs.

Requery of subform does not activate conditional formatting and puts new record at the bottom

I have a form with a 2-page tab control.
The first page has a subform with a button on the subform that's supposed to requery another subform that is on the second page.
Forms!myMainForm!mySubForm.Requery
The main form and its fields are used to create new records and the subform on the second page shows these records.
Here's a screenshot of page 1's subform and button:
http://i.imgur.com/RLsgcSi.jpg
When the button is clicked, the subform on the second page shows any new record at the bottom of the list instead of being sorted in descending date/time order. Also the Funding Rate field does not seem to get its conditional formatting applied:
http://i.imgur.com/QRvI5fy.jpg
I've been able to get the subform to display correctly if I also add some VBA to the button to switch to the second page of the tab, but I'd rather not do this.
Is it possible to requery a subform and have it display correctly when the user is ready to see it?
Migrate froms Tabs to Navigation Control. Usual Tabs are preloaded and will increase the main form load time. On the other hand, Navigation control only loads the form when its opened. This eliminates your needs to manually re-query the second tab.
PS: I'm interested in something in your form, what is your best contact method?
Forms!myMainForm!mySubForm.Requery
This requeries the mySubForm control on myMainForm, but not the subform itself.
Try instead:
Forms!myMainForm!mySubForm.Form.Requery
(note: I'm not 100% sure this will solve the issue)

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.

Phantom boxes in an Access 2007 form when viewed in Access 2010

I have an Access db (developed in Access 2007) set to display windows in tabbed view. It opens with a simple form to show the user various options. Since I made it, we upgraded to Access 2010.
Since this form was made for navigation to other forms (there is no underlying data set), it just has buttons in the Form Header that open other forms. Here's sample code from one of those buttons:
Private Sub Cmd_Lookup_Click()
DoCmd.OpenForm "Frm7a_Lookup"
End Sub
However, when these buttons are clicked, a dotted rectangle (about 1-2 inches in length and width) appears in the upper left of the form while the new form is loading. I have no idea where this 'phantom box' is coming from. There's no object in that area of the form and all the other objects in the form are visible and accounted for. So, there's nothing for me to delete.
It's visually unappealing and shouldn't exist. How do I make this phantom box go away? Do I have to rebuild the form from scratch?
The phantom boxes seem to appear when buttons (perhaps with pictures) from previous versions are on the form.
Try removing the buttons and re-adding them.