A Tab Control has three main objects:
[ol][li] The [blue]main control[/blue] itself.[/li]
[li]The [blue]Tabs[/blue].[/li]
[li]The [blue]Pages[/blue] the tabs are bound to.[/li][/ol]
Consider: you can only switch Pages by clicking Tabs! (not pages) . . . necessary to bring that page into view!
If you look closely . . . you'll see the properties window saids [purple]PageX[/purple] when you click a tab in design view. [blue]So your setting the MsgBox for the Page . . . not the tab.[/blue]
You can verify you code by clicking the tab, then clicking anywhere inside the tab (page)!
What you need to do is detect a page change and wether its the page of interest . . . easily done by the [blue]Change[/blue] event of the Tab control:
Code:
[blue] If Me![b]TabCtlName[/b] = [purple][b]1[/b][/purple] Then
MsgBox "hello"
End If[/blue]
Remember [purple]Page Index[/purple] starts at zero (0) . . .
You want to probably use the on change event.
Here is how you reference the current page. It is a little overkill, but trying to demonstrate some points.
Code:
Private Sub tbCntrlTest_Change()
Dim myPage As Page
Dim intPageNumber As Integer
intPageNumber = Me.tbCntrlTest.Value
Set myPage = Me.tbCntrlTest.Pages(intPageNumber)
MsgBox myPage.Name
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.