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

Detecting page changes on a form with multiple tabs 1

Status
Not open for further replies.

HowardB

Technical User
Aug 24, 2002
18
GB
Hi All,

Does anyone know whether there are any events or methods that would allow me to trigger code execution when I click on a tab to change the form page on a form with multiple tabs?

I have a form with multiple pages accessed via tabs at the top of the form. I want to trigger some data quality checks on the data entered on page 1 when the user clicks on the tab to go to page 2. I can find little information on any event or property that would allow me to do so if anyone can give me some information and/or code pointers it would be much appreciated,

HowardB
 
The control is called TabCtl0 and you could use the change eveent. Locate by right click on tab control. Here is an example of some code in one of my Forms.

Private Sub TabCtl0_Change()

Dim tbc As control, pge As Page, oldPge As Page
' Return reference to tab control.
Set tbc = Me!TabCtl0
' Return reference to currently selected page.
Set pge = tbc.Pages(tbc.Value)
' Enumerate controls on currently selected page.
''--Debug.Print "Page Name = "; pge.Name
''--Debug.Print "Last Page Name = "; glbLastPage

If (pge.Name = "Shop Order List") Then
glbLastPage = pge.Name
Exit Sub
Else
'--- Always go to the Equipment form to get the equipment Number
'--- when coming from the shop order
If glbLastPage = "tpShopOrder" Then
Forms!MotorDataEntry!tabsubformEquipment.SetFocus
End If
End If

glbLastPage = pge.Name
End Sub
 
Looks good! Thanks for the prompt reply ... have a star (but don't let it go to your head) :))
 
OK so this is a little embarassing but I can't find the tab control you mention? I am in form design mode. If I right-click on the one of the form tabs and go to properties I get the page properties. If I right click on the tab control in the toolbox I do not se a change event option. Can you give me an idiot's guide to finding the tab control you mention in your post,

Thanks HowardB
 
Not so embarassing as having conversations with yourself on forums though. It wasn't obvious but I have now managed to find and select the TabCtl0 you mentioned and I am on my way, Thanks again
 
Not so embarassing as having conversations with yourself on forums though. It wasn't obvious but I have now managed to find and select the TabCtl0 you mentioned and I am on my way, Thanks again
 
It sounds like you got it, but I usually go to the right of the last tab and find some space a tab does not occupy then right click and select properties.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top