PDA

View Full Version : Solved: Tabbed Pages Problem



jauner
11-16-2005, 10:51 AM
I have a form that has tab pages with subforms on it. Is there a way I can know which tab has been clicked or which subform is currently active? I need to conditionally set some subform fields based on which one is up.

:dunno

chocobochick
11-16-2005, 01:22 PM
When a different page is selected, the Change event is fired for the Tab Control object and the index for the newly selected page is stored in the tab's Value property. Value can then be used as the index for the Pages collection. So assuming your tab control is named tabCtl1 and it contains three pages named pag1, pag2, and pag3, (note: those are control names, not captions) you could use code like this in your form's module:

Option Explicit

Private Sub tabCtl1_Change()
Select Case tabCtl1.Pages(tabCtl1.Value).Name
Case "pag1"
' Insert Page 1 code here
Case "pag2"
' Insert Page 2 code here
Case "pag3"
' Insert Page 3 code here
Case Else
' Enter default code here
End Select
End Sub