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-01T15:26:31+00:00

    If you have a look at my original question posed on here, it's mentioned that .SetFocus don't work. It just sets the focus on the 2nd tab for instance but still shows the first tab and its vertical tabs. It doesn't go to the 2nd tab!

    Any revised code?

    0 comments No comments
  2. Anonymous
    2023-06-01T15:53:14+00:00

    Apologies for the misunderstanding. If setting the focus using . SetFocus does not switch to the desired tab in your specific scenario, you can try using the . Value property of the navigation control to programmatically switch the selected tab. 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 the Value property of the navigation control to the desired tab
            Me.NavigationControlName.Value = "NavigationButton1"
        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, replace NavigationControlName with the actual name of your navigation control. Then, set the . Value property of the navigation control to the desired tab's name (e.g., "NavigationButton1") to switch to that tab.

    Please note that the exact names of the navigation buttons may differ based on your specific form design. Adjust the code accordingly by replacing NavigationButton1 with the appropriate name of your desired 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
  3. Anonymous
    2023-06-01T16:12:46+00:00

    After extensive search on the Internet and lots of trials and errors, my answer to my question regarding the missing code is:

    If Not NavigationButton1.Enabled Then

    SendKeys "{TAB}", True 
    
    SendKeys "{ENTER}" 
    

    End If

    Just for the record!

    0 comments No comments
  4. Anonymous
    2023-06-01T16:28:20+00:00

    I am glad to know that issue is resolved for you, Sorry for Inconvinice caused.

    It was my pleasure to assist you.

    Best Regards, Sneha

    0 comments No comments