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!

How to execute an event upon changing a tab page 1

Status
Not open for further replies.

rew2009

Technical User
Apr 21, 2009
114
US
My form has a number of tabbed pages. When I change from one page to another with the click of a tab I would like to execute an event to fill a text box with a value from the current record field. I have the code to fill the text box and currently do it from a cmd button on that new page but would like to do it automatically when the tab control changes to that page. I am sure it is simple, but I haven’t figured out where the event property of a particular tab page is located. Thanks
 
Could you not use the tabs Change event?

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
I tried that approach but it executes the same event when any of the tabs is clicked. If that is the only way to do it then I would have to have an "if then" statement to only execute if the focus is on a particular tab page such as "City". I tried the following code but the language or syntax is not correct. Could you tell me the correct code or a another way to do it.

If Me.TabCtl0.Pages("CITY").SetFocus Then
'my code for that tab page event
End If

Thanks
 
The .Value property of the TabControl is a 0 based value indicating which tab is selected, you can use that.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
I think we are on the right track but I still got an error when using this code:


Private Sub TabCtl0_Change()

If (tabct.VALUE = 5) Then
'My code
End If

End Sub

Thanks
 
I still got an error
Which error message ?
Which line of code highlighted when in debug mode ?

Anyway, I'd replace this:
If (tabct.VALUE = 5) Then
with this:
If tabctl0.VALUE = 5 Then '6th tab

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yep, I'd second PHV in both his comments. If I'd been a bit faster that's excetly what I would have asked/said [smile]

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
Thanks Harley, That worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top