Home > front end >  how to hide tab control on opening the form?
how to hide tab control on opening the form?

Time:06-13

I currently have a tab control with 4 tabs. Each tab is tied to a checkbox, in which the tab will open when the checkbox clicks.

However, I am struggling with how to hide the entire tab control or tabs upon opening the form. Ergo, I only want the tabs to start appearing when boxes are ticked. Whereas right now, the tabs all appear when the forms open.

my current code is this:

Private Sub Type_C_Click()
If Me.Type_C = vbTrue Then
    Me.Section_III__Cybersecurity.Visible = True
    
Else
    Me.Section_III__Cybersecurity.Visible = False

End If

End Sub

Private Sub Type_D_Click()
If Me.Type_D = vbTrue Then
    Me.Section_IV__Data_Security.Visible = True

Else
    Me.Section_IV__Data_Security.Visible = False

End If

End Sub

Private Sub Type_I_Click()
If Me.Type_I = vbTrue Then
    Me.Section_V__ICT_Outage.Visible = True

Else
    Me.Section_V__ICT_Outage.Visible = False
End If


End Sub

Private Sub Type_G_Click()
If Me.Type_G = vbTrue Then
    Me.Section_VI__Loss_of_Government_Issue_Equipment.Visible = True

Else
    Me.Section_VI__Loss_of_Government_Issue_Equipment.Visible = False
End If

End Sub

I've tried to use form current and hide the visibility of the tab control, however, subsequently none of the tabs will appear when the boxes are ticked. Similarly, I've tried to hide individual tabs in form current, however i get error 2156 where one of the tabs is the focus and I can't seem to bypass it.

Any help would be greatly appreciated!

CodePudding user response:

Make sure checkbox TripleState property is set to no. Set each Tab page Visible property to no in form design.

Before setting page to not visible, set focus to some other control on form that is not located on any of the pages because page that has focus cannot be set not visible. Conversely, after setting a page visible, put focus on a control located on that page.

  • Related