Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab control and page control displaying different fields/controls based on tab page selected 1

Status
Not open for further replies.

Triacona

Technical User
Jun 11, 2009
462
GB
Dear All,
Thank you for a great forum!

I have the following problem.
I have several tab pages within a tab control.
Base on the tab page selected I want certain labels and text boxes to be visible/not visible and enabled/not enabled.

The main tab control is called:
tabCtlBcMain

The tab pages are called:
tabAbout
tabBuildingControlOperations
tabContraventions
tabDangerousStructures
The tab pages are my concern.
I tried the following and it does not seem to work:
Code:
[COLOR=Blue]Private Sub[/color] tabAbout_Click()
    
    tabAbout.SetFocus
    [COLOR=Green]'enabled state T/F [/color]
        txtStartDate.Enabled = [COLOR=Blue]False[/color]
        txtEndDate.Enabled = [COLOR=Blue]False[/color]
        cmdCalDate.Enabled = [COLOR=Blue]False[/color]
        cmdCalDateEnd.Enabled = [COLOR=Blue]False[/color]
        txtArea.Enabled = [COLOR=Blue]False[/color]
   [COLOR=Green] 'visibility [/color]
        LbStartDate.Visible = [COLOR=Blue]False[/color]
        txtStartDate.Visible = [COLOR=Blue]False[/color]
        lbEndDate.Visible = [COLOR=Blue]False[/color]
        txtEndDate.Visible = [COLOR=Blue]False[/color]
        cmdCalDate.Visible = [COLOR=Blue]False[/color]
        cmdCalDateEnd.Visible = [COLOR=Blue]False[/color]
        txtArea.Visible = [COLOR=Blue]False[/color]
        lbArea.Visible = [COLOR=Blue]False[/color]
    tabAbout.SetFocus
[COLOR=Blue]End Sub [/color]
I have tried variations of events - Change, Load...
This does not work.
Please help, I have tried for hours and search online up and down and nothing seems to be similar enough to guide me.
Thanks for your forthcoming help [smile]


Thank you,

Kind regards

Triacona
 
No. Use the Change event of the tab control not individual pages. Value of the tab control is the page index. Pages are indexed 0 to N-1

Code:
Private Sub tabDemo_Change()
    Select Case tabDemo.Value
    Case 0
      'do some code for the first tab
    Case 1
       'do some code for second tab
    Case 2
       'do some code for third tab
    End Select
End Sub
 
Thanks so so so much!!
Works perfectly!

Thank you,

Kind regards

Triacona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top