0
votes

(MS Access 2016) I'm trying to change the selected tab on a NavigationControl on another form. This is my forms structure:

frm_nav > navSubForm(displaying: "frm_src_ma") > reSubForm ; reSubMenu

navSubForm: name of the Sub Form Control on frm_nav

reSubForm: name of the Sub Form control of the NavigationControl on frm_src_ma

reSubMenu: name of the Navigation Control on frm_src_ma

Now there are two tabs on reSubMenu:

  • Data [navData ("frm_subsrc_ma")]
  • Instances [navInstances ("frm_subinst_ma")]

On a floating form i have a button that when clicked i want reSubMenu to change tabs to Data whenever Instances is selected.

This is the code inside the Click Event on said button:

Forms![frm_nav]![navSubForm].SetFocus

DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
    ObjectName:="frm_subsrc_ma", _
    PathToSubformControl:="frm_nav.navSubForm>frm_src_ma.reSubForm", _
    DataMode:=acFormEdit

When either Data or Instances is selected and the button is pressed it throws this error: The macro action BrowseTo requires a valid Path argument

Screenshots for reference:

Error being displayed

Forms structure

1
ObjectName property must reference a form or report that loads inside subform container, not the container name. - June7
Yes, i've read the documentation on the Path argument, however i'm not able to see where i've made the mistake on the path. June7 - It is indeed the actual form name "frm_subsrc_ma" not the subform control name, the control's identifier is reSubForm - Loui
Why would both tabs reference same form? Description is not making sense. I tested code and have no problem referencing subform of a second level navigation form to get focus on specific tab. Perhaps you need to provide images of form design. - June7
They don't reference the same form it was a typo on the original post. I've now corrected that and added screenshots of the UI for reference. - Loui

1 Answers

0
votes

It seems that the problem had to do with what was being focused before applying BrowseTo. For the full path to be valid, the main form was focused instead of any subform inside it.

Forms![frm_nav].SetFocus

DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frm_subsrc_ma", _
PathToSubformControl:="frm_nav.navSubForm>frm_src_ma.reSubForm", _
DataMode:=acFormEdit