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

Tab Control Events 1

Status
Not open for further replies.

foreveryoung

Programmer
Sep 24, 2002
45
GB
On a Tab control I want an event to fire when I click on the top (tab) bit of it. Is there a way of doing this. The rest of the control has a click event but not the tab part of it.

Ideally when I go from one tab to the next I want an event I can write code into.

Thanks
David
 
I would suggest that you put a transparent button over the tab to carry out any functions you require and then open up the tab page.

Hope this is of use.

 
I have tried doing this but it wont let you put a button on top of the tab???
 
How about having multiple forms - one for each "page" and a button at the top to act as a tab.

Clumsy, but it should serve.

 
Yes I could do that, is a bit clumsy like you say. Would still be nice if there was an event when the tab bit is clicked. Apparently the tab control is made up of two main windows, one for the data to go onto and one for the tabs. That is why the click event only fires when the main part (bit for the data) is clicked.

Thanks for your help!
 
There are tab control events? Some events are OnEnter and OnExit. So, you can insert code when changing tabs on a Form. Is this what you are looking for????
 
I have accomplished my goal here. The change event of the tab control fires whenever you go from one control to the next.

Dim tbc As Control, pge As Page
Dim ctl As Control

' Return reference to tab control.
Set tbc = Me!TabCtl159
' Return reference to currently selected page.
Set pge = tbc.Pages(tbc.Value)

If pge.Name = "MidwifeContacts" And txtID = "" Then
Call cmdsave_Click
Exit Sub
End If
====================================================
I didnt need this but left it in incase anyone was interested. It enumerates all the controls on whatever tab sheet you want.

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

Many thanks to all those who kindly helped me out!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top