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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onclick for tab not working

Status
Not open for further replies.

OnLiner

Technical User
Dec 4, 2002
87
0
0
US
Hi everyone,

I put this in the onclick event for a tab...

MsgBox "hello"

and its not working.

Anyone know why?

Thanks mountains yet again :)
 
How are ya OnLiner . . .

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) . . .

Calvin.gif
See Ya! . . . . . .
 
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
 
fantastic thanks that did the trick! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top