Finally, I have figured out the limitations of using the “Browse To”. Whether you are creating a macro or actually writing the code, the failure can be a result of two factors:
- You did not reference the form path correctly.
- You lost the value of the search field(s).
Keep in mind that this is only applicable to using the new Navigation controls.
Let me begin by explaining my navigation. I click the “Lookup” button and select a letter from the alphabet (hyperlinks with onclick code), which populates a combo box. From the combo box, a selection is made, and a contact card is populated.
From the “Lookup” subform, I want to click the hyperlink and navigate to the “Edit” subform.
In order to this, you must follow a set of steps to keep the value that you use to search as well as to be able to open the subform. Let’s begin with how my field is referenced on the “Lookup” form.
Navigation is the name of the form that holds the navigation tabs and their second level buttons. Search is the actual area or subform under the buttons. “Search” is not the target of the button. It is the subform that holds the button’s target. Try and keep this straight. The target is set in the button’s property, i.e. Lookup or Edit.
If you were to click the button “Lookup” in Design View and go to the Data tab, you would see the Navigation Target Name is “ContactCard”. If you looked at the same property for the button “Edit”, you would see the value as “ContactList”. The target names are not relevant. This was hard for me to overcome, and I learned by accident.
The part that you need for the Path to Subform Control is “Navigation.Search” in the macro. (Why I used “Search” is only because I failed to rename it after I had built the app. I suggest you name it “NavSub” to omit any confusion.)
Let’s address how to keep the value of the filed that you are searching or for which navigation is based. In this instance, the value is coming from the field “ContactID“.
You will need to create a temporary variable to hold this value. Once you browse from this form, you will lose the value. In your macro, choose “SetTempVar” and give it a name.
To find the path to Lookup-ContactID, I opened the navigation form, clicked the tab, and clicked the button to view the “Lookup” form. I left this open. I returned to the macro group where I had begun the submacro group, “editlookup”.
I used the Expression Builder to find the field. I clicked my way through to Loaded Forms, Navigation, and the name of the form that was the target for the “Lookup” button. From the list of controls, I found the field “ContactID“.
On double-click, Access puts [Forms]![Navigation]![Search].[Form]![ContactID] in the expression text box. I clicked OK. My temporary variable will now have a value.
You can see a clip of the full macro here ….
All that is left is to fill in the fields in the BrowseTo of your macro. Click the graphic above to view in full screen. I hope this helps.
I stumbled for quite some time until I realized that loosing focus, loosing values, and wrong paths were things that I took for granted or expected to be much more complicated than they actually were.