trigger an event by changing pages in a tab control form

K

Kirk

How can I trigger a code event by switching pages in a form with a tab control?
In design view with the page selected the only events that show up on the
property sheet are: On Click (which does not activate on clickign the tab but
the page itself), on Dbl click (same issue) and 3 mouse actions.

Any other way to activate code only when the target page is selected by
clicking on it's tab?
 
L

Linq Adams via AccessMonster.com

Your problem is that you have to select the Tabbed Control, not an individual
page.

The event to use is the Tabbed Control OnChange event. Here's an example:

Private Sub YourTabbedControlName_Change()
Select Case YourTabbedControlName
Case 0 ‘First Page
‘Code for Page 1
Case 1 ‘Second page
‘Code for Page 2
Case 2 ‘Third page
‘Code for Page 3
End Select
End Sub

Notice that the pages are Zero-based, i.e. the first page is 0, the second
page is 1, etc. Just replace

YourTabbedControlName

with the actual name of your Tabbed Control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top