Page Object, Pages Collection Example
The following event procedure enumerates all the controls on each page of a tab control when the user selects that page.
To try this example, create a new form with a tab control named TabCtl0 and set its OnChange property to [Event Procedure]. Paste the following code in the form's module. Switch to Form view and click on the different tabs to enumerate their controls.
Private Sub TabCtl0_Change()
Dim tbc As Control, pge As Page
Dim ctl As Control
' Return reference to tab control.
Set tbc = Me!TabCtl0
' Return reference to currently selected page.
Set pge = tbc.Pages(tbc.Value)
' Enumerate controls on currently selected page.
Debug.Print pge.Name & " Controls:"
For Each ctl In pge.Controls
Debug.Print ctl.Name
Next ctl
Debug.Print
End Sub