Execute code on tab click

skwilliams

Registered User.
Local time
Today, 10:21
Joined
Jan 18, 2002
Messages
516
I have a main form with a tab control. There is one subform under each of four tabs.

I would like to execute code on the subform under tab 2 when tab2 is selected.

Can anyone help?

Thanks.
 
You need to place the code in the tab controls OnChange event. This is different the events on each independant tab.

Try pasting this code in, making sure to change the name of the Tab Conrtol to what yours is called

Private Sub TabCtl0_Change()
If TabCtl0.Value = 1 Then MsgBox "Test"
End Sub


The value for the first tab is 0, the second tab is 1, etc.

If you change the name properly then the message box Test should show up as you click on the second tab.

Once you have that figures out so it fires off for the tab you need then just replace the code for the MsgBox with what you want.
 

Users who are viewing this thread

Back
Top Bottom