-----Original Message-----
Hi Susan,
You need to use the Change event of the TabControl itself - it fires
whenever you click on a tab page. The value of the TabControl will
tell you which page is being brought into focus (or has been
clicked). Following are two ways to do this - the first uses a
hardcoded value for the comparison pageindex. Note that the
pageindex of the first page is 0.
The second method uses the name of the page to get the comparison
page index. This is just a bit more robust and helps avoid problems
if you add or reorder pages.
Private Sub MyTabControl_Change()
Select Case Me.MyTabControl
Case 0
MsgBox "First Page"
Case 1
MsgBox "Second Page"
End Select
' Same thing, using an indirect method for getting the pageindex
Select Case Me.MyTabControl
Case Me.MyTabControl.Pages("Page1").PageIndex
MsgBox "First Page"
Case Me.MyTabControl.Pages("Page2").PageIndex
MsgBox "Second Page"
End Select
End Sub
--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.
I have a form with multiple pages and would like to change the
record source and set the focus to a specific control when the page
tab is clicked. I have added the code to the On Click event for
the page, but the code is only being executed when I click
elsewhere on the form once the new page is active. Is there a way
to get it to work when the tab for a page is clicked?
Thanks.
Hi Sandra,
I've been looking thoughout the messages for tips for my
difficulties. The one you replied to on 10/26/03 to Susan
helped a bit. Right now I'm working on a DB for my coin
collection. One to help me organise which countries I
have. A few months ago, I noticed the TAB method, and
getting them to link together doesn't want to work. Right
now I'd like to have all the country names on TAB I, once
you highlight one and press TAB II you get a list of all
the coins for that country. Then after you highlight one
of the coins, and press TAB III, you get all the qualities
for that coin. Then, pressing TAB IV, you get a list of
how the value of such coin has changed over the years.
This will be a place to put the value I get for its' value.
Each country has an ID#, which I thought would make it
easier to link throughout, but I'm not having any luck.
Any help would be appreciated,
Dave