Home > Back-end >  Controlling the visibility of tabs in a subform
Controlling the visibility of tabs in a subform

Time:07-18

Currently implementing toggle buttons that controls the visibility of tabs in a subform. When opening the subform on its own, the toggle buttons work, however when I am on the main form, the toggle buttons don't work anymore.

Private Sub Toggle53_Click()
If Me.Toggle53.Value = True Then 
   Me.IDD.Visible = True 
   Me.IDS.Visible = True 
  Else 
   Me.IDD.Visible = False
   Me.IDS.Visible = False 
End If 

I also tried implementing this code in Private Sub Form_Current() for the subform's current event, but it doesn't work either.

Any help is appreciated thanks!

CodePudding user response:

Don't know the structure of your forms, but to hide a tab using a toggle button, you need to reference the tab by index as shown below. Obviously, if the tab control is located in a subform control, you will need to change the reference to it.

Private Sub Toggle1_Click()
    TabCtl.Pages(0).Visible = Toggle1.Value
End Sub

If the tab control is located in a subform control:

Private Sub Toggle1_Click()
    SubformControl.Form.TabCtl.Pages(0).Visible = Toggle1.Value
End Sub

CodePudding user response:

If all the forms are on the page you could add condittional If on them with booleans to show them, so on toggle click just set everyones boolean to false except the item you want to be visible. For example create boolean called IDDbool=false, bind it to the subform and change it on click to true to show it.
Also option is to create method on the sub form that controls the tabs and call in that method from the main one.

  • Related