Navigation Form

Anonymous
2023-06-01T11:37:38+00:00

A navigation form with Horizontal Tabs & Vertical Tabs (Left or Right) was created in the Main Form using "Create; Form; Navigation" of the toolbar:

The Form_Load Event of Main Form with x1 and x2 dimmed as public variables:

Private Sub Form_Load()

If x1 = 0 then NavigationButton1.Enabled = False

If x2 = 0 then NavigationButton2.Enabled = False

End Sub

The above code works well. However, I want the first horizontal enabled tab is shown after the Main Form is loaded or opened.

NavigationButtonx.SetFocus makes the focus on the first enabled tab but it doesn't show its related Vertical Tabs.

What would be the missing code?

Thanks

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

9 answers

Sort by: Most helpful
  1. Anonymous
    2023-06-01T13:17:56+00:00

    Hi,

    I'm Sneha and I'd be happy to help you out with your question. Sorry for the inconvenience caused.

    To ensure that the related vertical tabs are displayed when setting the focus to the first enabled horizontal tab in your navigation form, you can use the SetSelectedTab method of the navigation control. Please follow the modified code below:

    Private Sub Form\_Load()
        ' Check if x1 is equal to 0
        If x1 = 0 Then
            ' Disable NavigationButton1
            NavigationButton1.Enabled = False
        Else
            ' Enable NavigationButton1 and show its related vertical tabs
            NavigationControl.SetSelectedTab NavigationButton1
        End If
        
    ' Check if x2 is equal to 0
        If x2 = 0 Then
            ' Disable NavigationButton2
            NavigationButton2.Enabled = False
        End If
    End Sub
    

    In the code above, make sure to replace NavigationControl with the actual name of your navigation control. Also, ensure that the variables x1 and x2 are properly initialized and contain the appropriate values based on your specific requirements.

    By using the SetSelectedTab method with NavigationControl.SetSelectedTab NavigationButton1, you are setting the focus to the first enabled horizontal tab (NavigationButton1) and ensuring that its related vertical tabs are displayed accordingly.

    For more Information, please refer to following resources :-

    1. Access 2010 - Navigation Page, cannot set focus to "inside" form - https://answers.microsoft.com/thread/7c63bdb6-125c-4394-8552-281c8966f0c9
    2. NavigationButton.SetFocus method (Access) - https://learn.microsoft.com/office/vba/api/access.navigationbutton.setfocus

    If you have any other questions or need assistance with anything, please don't hesitate to let me know. It will be my pleasure to Assist you.

    Best Regards, Sneha

    Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom.

    0 comments No comments
  2. Anonymous
    2023-06-01T13:39:24+00:00

    Hi,

    I'm Percy and thank you for the reply.

    Could you please let me know where I can find the name of my navigation control NavigationControl in the above picture?

    Regards

    0 comments No comments
  3. Anonymous
    2023-06-01T13:48:16+00:00

    In the picture you provided, the navigation control might not have been named "NavigationControl" by default. To find the actual name of your navigation control, you can follow these steps:

    1. Open the form in Design View in Microsoft Access.
    2. Select the navigation control, which is the container for your horizontal and vertical tabs. It may be a rectangular box or frame containing the tabs.
    3. Look for the "Property Sheet" button in the "Design" tab of the ribbon and click on it. Alternatively, you can press F4 to open the Property Sheet.
    4. In the Property Sheet, locate the "Name" property. The value displayed in this property represents the name of the navigation control.
    5. Take note of the name displayed in the "Name" property. This is the name you should use in your code instead of "NavigationControl" to refer to the navigation control.

    By following these steps, you will be able to identify the actual name of your navigation control and replace "NavigationControl" with the correct name in the code provided.

    If you have any other questions or need assistance with anything, please don't hesitate to let me know. It will be my pleasure to Assist you.

    Best Regards, Sneha

    Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom.

    0 comments No comments
  4. Anonymous
    2023-06-01T14:24:38+00:00

    Following your instruction, there's no name for the Navigation control as depicted below:

    Image

    We can only see the names of tabs or different parts of navigation form not the navigation control.

    It also seems that there's no such a .SetSelectedTab in VBA!

    0 comments No comments
  5. Anonymous
    2023-06-01T15:02:31+00:00

    In Microsoft Access, the navigation control itself does not have a distinct name property. Instead, each individual tab within the navigation control has its own name. The tabs are typically referred to as "NavigationButton" followed by a number.

    To set the focus on the first enabled tab and display its related vertical tabs, you can use the Value property of the navigation control along with the SetFocus method. Here's an updated version of the code:

    Private Sub Form\_Load()
        ' Check if x1 is equal to 0
        If x1 = 0 Then
            ' Disable NavigationButton1
            Me.NavigationButton1.Enabled = False
        Else
            ' Set focus on NavigationButton1 and display its related vertical tabs
            Me.NavigationSubform.Form.NavigationButton1.SetFocus
        End If
        
    ' Check if x2 is equal to 0
        If x2 = 0 Then
            ' Disable NavigationButton2
            Me.NavigationButton2.Enabled = False
        End If
    End Sub
    

    In the code above, Me.NavigationSubform.Form.NavigationButton1.SetFocus sets the focus on the first enabled horizontal tab (NavigationButton1) and displays its related vertical tabs.

    Please note that the exact naming of the navigation buttons may differ based on your specific form design. Make sure to adjust the code accordingly by replacing NavigationButton1 with the appropriate name of your first horizontal tab button.

    If you have any other questions or need assistance with anything, please don't hesitate to let me know. It will be my pleasure to Assist you.

    Best Regards, Sneha

    Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom.

    0 comments No comments