Form page tab events

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to activate an event when I click on the tab (label) of a page form
(one of the tabs themselves).

So far, I can only manage this on the individual page itself. In other
words, you are presented with a form containing several pages each identified
by a differnt tab. If you select one of the tabs you go into that page but I
can only fire off an event when I first select the tab and then click
somewhere on that page.

Can an event be activated as soon as you select the individaul tab?

Thanks.
 
Andy said:
I need to activate an event when I click on the tab (label) of a page
form (one of the tabs themselves).

So far, I can only manage this on the individual page itself. In other
words, you are presented with a form containing several pages each
identified by a differnt tab. If you select one of the tabs you go
into that page but I can only fire off an event when I first select
the tab and then click somewhere on that page.

Can an event be activated as soon as you select the individaul tab?

Thanks.

Hi Andy,

You bet! You need to use the TabControl_Change event. Every time
you select a different tab the change event fires.

I use a Select statement to determine the code to run.

Select Case Me.TabControl.Value

Case 0 ' We just selected the 1st tab
' Do 1st tab stuff
Case 1 ' We just selected the 2nd tab
' Do 2nd tab stuff
Case 2 ' We just selected the 3rd tab
' Do 3rd tab stuff
Case Else
' It wasn't tabs 1 to 3
End Select

HTH
 
Open the form in design view, open the properties by pressing the Alt+Enter.
Now click on the title of the TAB you want the event to activate from,
select the OnClick Property, select code, and enter the code you want to take
place when you select that TAB.
 
Andy said:
Thanks but where is this code applied - form load, form activate etc.?

Hi Andy,

The code is applied in the TabControl_Change event.

It can be a little difficult to locate. In design mode click on the
tab control one time. Right click and go to properties. If you do
not have a Change event then you are looking at a property sheet
of one of the tabs. Use the combo box and look for something with
a name like 'TabCtl9' and go to that sheet. It should have a Change
event. Click on the '...' and away you go!

Post back if you need any more assistance. I'd be happy to help.

<snip>
 
Ofer said:
Open the form in design view, open the properties by pressing the Alt+Enter.
Now click on the title of the TAB you want the event to activate from,
select the OnClick Property, select code, and enter the code you want to take
place when you select that TAB.

Sorry, but that is not how the Click event of a TabPage works. It does not fire
when you select a page. In fact it does not fire when you click on the "tab"
portion of the page at all.

You need to use the Change event of the entire TabControl as other posters have
already suggested.
 
Thank you Rick.
You are absolutly right, my mistake.
With my suggestion it will trigger an event only when clicking on the tab,
and not on the title of the tab.
Thank you again for clarifying that for me, I appriciate that.
 
I have a similar issue, and put code in the tab change event as suggested.
The code fires off, but it goes to the new tab first. My code needs to
prevent going to the new tab, because there were errors detected. I can
finish up by setting focus to the original tab, but then my code fires off
again.
 
Back
Top