Full Version: Tab controls and events
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
KurtW
Hey all:

I need a bit of help with tab controls. I have a main form with three tabs on it. (1 tab control, 3 separate tabs.) The main form has a generic status message field at the bottom that is set through a public/global function, so this field services all tabs.

I'd like the message text reset to blank when the user switches tabs. I have tried calling the message function in the OnClick event of the 3rd tab, like so (the tab is called EDIT:

Private Sub Edit_Click()
Call subSetStatusMsg("", "Hide", 0)
End Sub

… but nothing happens. Is there something obvious I am missing? Is there a better way to handle this?

Thanks

Kurt
fredrisg
Use the OnChange event of the tab control itself . . . I do the same basic thing myself!

And if you work on a slow server, you can set up some form variables and use the OnChange event to load cbos and listboxes . . . if the user goes to a given tab . . . if not, you don't pay any penalty on opening the form. Some posters have brought this to my attention.

Finally, if you move controls from tab to tab (page to page), any events to the moved control become 'unlinked'. The code is still there but you'll have to relink it manually . . .

But I do love this control!

Steve
Jack Cowley
Use the On Change event of the control itself:

Select Case NameOfYourTabControlHere
Case 0 'first tab
..do whatever..
Case 1 'second tab
...do whatever...
Case...
etc.
End Select

hth,
Jack
KurtW
Thanks to you both! That was exactly what I needed. Fantastic.

Kurt
Jack Cowley
You are welcome and good luck with this...

Jack
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.