3
votes

In an ms access 2010 database, I have a listbox whose afterupdate procedure needs (among other things) to navigate to a specific tab in a navigation subform. I can get it to change the SourceObject property of the navigation subform, but the selected tab does not get changed, so the user ends up seeing the right source object with the wrong tab selected. This looks unprofessional. How can I change both the selected tab and the source object?

I uploaded a simplified database that recreates the problem to this file sharing site.

The list box that needs its afterupdate method changed is called lstbxClients. Here is my current draft of its afterupdate method, which is currently throwing an error:

Private Sub lstbxClients_AfterUpdate()
  Dim rst
  Set rst = Me.RecordsetClone
  rst.FindFirst "ClientNumber = " & lstbxClients.Column(0)
  Me.Bookmark = rst.Bookmark
  'Forms!Main!NavigationSubform.Form!NavigationSubform.SourceObject = "qryListCommunicationForms"
  DoCmd.BrowseTo acBrowseToForm, "qryListCommunicationForms", "Forms!Main!NavigationSubform.Form!NavigationSubform"
  Form.NavigationSubform "  "
  'Forms!Main!NavigationSubform.Form!NavigationSubform.SelectedTab = "CommFormsNavBtn"
  Set rst = Nothing
End Sub  

How do I change the code above so that it changes both the selected tab AND the source object of the navigation subform when the user clicks on a different record in the listbox?

3
My apologies - I was looking at two questions, and typed the answer for the other one into yours. It actually was a C to C# question. I have deleted my answer, but if you actually saw something worthwhile in it post here and I will restore.Pieter Geerkens

3 Answers

2
votes

Access gave a relatively decent explanation of what the proper syntax of the path is.

Path argument is of the form: MainForm1.Subform1>Form1.Subform1

So your BrowseTo command should look like this:

DoCmd.BrowseTo acBrowseToForm, "qryListCommunicationForms", "Main.NavigationSubform>FindClientsNavigation.NavigationSubform"

1
votes

Use the syntax below

DoCmd.BrowseTo acBrowseToForm, "qryListCommunicationForms", "Main.NavigationSubform>findClientsNavigation.NavigationSubform", "ClientNumber = " & lstbxClients.Column(0)

and

DoCmd.BrowseTo acBrowseToForm, "ListAddresses", "Main.NavigationSubform>findClientsNavigation.NavigationSubform", "ClientNumber = " & lstbxClients.Column(0)

The only change is the second parameter syntax , use

"Main.NavigationSubform>findClientsNavigation.NavigationSubform"

Hope this helps

0
votes

The easiest way to do it :

Form_NavFormName.NavigationSubform.SourceObject = "FormName"