Solved How do I DoCmd.BrowseTo a NavigationSubform(s) form

oxicottin

Learning by pecking away....
Local time
Today, 15:57
Joined
Jun 26, 2007
Messages
870
I have a frm_Main with a NavigationSubform called (NavigationSubform) and the particular tab I need to open is called (NavigationButton40) and the form thats on that tab is called (frm_ProductHoldData). I have a button on another tab that I want to press and have it open the (frm_ProductHoldData) and I can't get the syntax correct.

Code:
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
 ObjectName:="frm_ProductHoldData", _
 PathToSubformControl:="Main_Form.NavigationSubform", _
 DataMode:=acFormEdit
 
I may depend on where the button is. Can you post a screenshot?
 
I may depend on where the button is. Can you post a screenshot?
An image I think would be confusing to look at and after you said that I messed up on the "Where" in my first explamation.

I have a frm_Main with a NavigationSubform called (NavigationSubform). The button is located on a forms subform (sfrm_Switchboard) (frm_Main/frm_Switchboard/sfrm_Switchboard AND it needs to open to a record in the form ((frm_ProductHoldData). Before I tried this navigation tabs below is how I opened to the record.

Code:
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frm_ProductHoldData"

    stLinkCriteria = "[HoldID]=" & Me![txtHoldID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria, , , "InSearchMode"

    'Forms!frm_ProductHoldData.txtDescreteJob.SetFocus    ' Sets focus to descret job


    'Moves record to the last record
    With Forms!frm_ProductHoldData.Recordset
        If .RecordCount > 0 Then .MoveLast
    End With

Hope this explains better....
 

Attachments

  • 1.JPG
    1.JPG
    225.9 KB · Views: 39
  • 2.JPG
    2.JPG
    250.6 KB · Views: 38
This built in navigation system MS has is horrible.... It looks good but in order to move around and link/open other tabs is a bear and confusing! BUT I still wanta learn it.
 
Have you tried changing the sourceobject for the subform on frm_Main? You could have a hidden unbound text box on your frm_Main and set the value of it with the subform button click and then with the frm_ProductHoldData open/load event you could filter the recordsource with the text box value.

Code:
Me.Parent.Parent.NavigationSubform.SourceObject = "frm_ProductHoldData"
 
I did find an example (Forget where) of someone else asking a similar question and theirs works using a macro which I hate using them. I'm going to play around with what I found to see how this works...
 

Attachments

You can convert macro to vba.
 
This built in navigation system MS has is horrible.... It looks good but in order to move around and link/open other tabs is a bear and confusing! BUT I still wanta learn it.
It is built to operate a certain way. You are not using it as the designers intend it to be used. If you want non-standard functionality, build your own form. That's what professionals do. They do not use forms like the navigation form if they can't live with the limitations.

The specific issue is almost always that the navigation form allows only a single subform to be open at any one time.
 
@Pat Hartman I usually make my own which is way simpler than using this. Thanks fellas for the advice and help but im not going to proceed with this anymore.
 
It's a fact that the Navigation Form is not well documented. But DoCmd.BrowseTo has some documentation to experiment with. I created the attached database to try to explain how to work with the Navigation Form. It is not so difficult once we know the behavior.

Here's the rules:
1. DoCmd.BrowseTo does not require a path if the calling form and the target form belong to the navigation form
2. If the calling form or the target form do not belong to the navigation form, then you need to specify a path
3. Paths must always end in a subform control
4. The syntax must start with the main form
5. Here's the code inside the attached database:

Code:
Option Compare Database
Option Explicit

Private Sub btnViewInTab_Click()
    ' Navigate to the "f_ParentDetails" form within the subform holding this form
    ' This will only work if the subform holding this form has the "f_ParentDetails" form associated with it
    DoCmd.BrowseTo acBrowseToForm, "f_ParentDetails", , "ParentID = " & Me.ParentID
   
    ' Alternatively, we can specify the exact path for more consistency:
    ' DoCmd.BrowseTo acBrowseToForm, "f_ParentDetails", "Main.Subform0>MyNavigationForm.NavigationSubform0", "ParentID = " & Me.ParentID
End Sub

Private Sub btnViewHere_Click()
    ' f_OrangeForm is not associated to the subform that holds this form, so it does not browse to any tab
    ' Resulting in the opening of the "f_OrangeForm" in the subform holding this form
    DoCmd.BrowseTo acBrowseToForm, "f_OrangeForm"
   
    ' Alternatively, we can specify the exact path for more consistency:
'     DoCmd.BrowseTo acBrowseToForm, "f_OrangeForm", "Main.Subform0>MyNavigationForm.NavigationSubform0"

    ' We can open unassociated forms in any tab like this:
'     DoCmd.BrowseTo acBrowseToForm, "f_OrangeForm", "Main.Subform0>MyNavigationForm.NavigationSubform0>f_ParentDetails.ChildrenListSubform"

    ' It can not browse to itself,
    ' the filter does not work and its subform breaks because it can't hold its parent
    ' No errors, though
'    DoCmd.BrowseTo acBrowseToForm, "f_ParentDetails", "Main.Subform0>MyNavigationForm.NavigationSubform0>f_ParentDetails.ChildrenListSubform", "ParentID = " & Me.ParentID
End Sub

Private Sub btnViewInNav_Click()
    DoCmd.BrowseTo acBrowseToForm, "f_ParentDetails", "Main.Subform0", "ParentID = " & Me.ParentID
End Sub

Code:
Option Compare Database
Option Explicit

Private Sub btnViewDetails_Click()
    ' The subform holding this form is NOT the navigation form
    ' Therefore, the following code will not browse to the required tab
'    DoCmd.BrowseTo acBrowseToForm, "f_ChildDetails", , "ChildID = " & Me.ChildID

    ' If we want to browse to the required tab, we must specify the path
    DoCmd.BrowseTo acBrowseToForm, "f_ChildDetails", "Main.Subform0>MyNavigationForm.NavigationSubform0", "ChildID = " & Me.ChildID
End Sub

Feel free to experiment by commenting/uncommenting code to see what happens
 

Attachments

Users who are viewing this thread

Back
Top Bottom