I HAVE JUST TRIED THE IDEA I HAVE EXPLAINED BELOW AGAIN AND IT DOESN'T ALWAYS WORK, SORRY. For example, if/when the controls loose their focus! My idea depends on how or if you are able to shepherd users around the form???
The above text was added after I wrote the text below. ___________________________________________
I don't believe you can do this directly. You have to do it indirectly. In the Tab control you can run an event when you click either a tab i.e. any of the tabs, or when you click the background of a particular page. Neither of these options helps you.
You could run the macro from a control on the form, such as an unbound field, say it's called Text3. Run the macro from the OnFocus event. Now hide the field behind some other object. (I'll explain why later.)
In the Tab control, probably called TabCtl0 or something like that enter the following code to run on the OnClick event.
Page2.SetFocus
You will also need to set the focus in other parts of the form so that certain controls keep thier focus at the right time. The entire code could read something like:
Private Sub Form_Current()
Page1.SetFocus
End Sub
___________________________________________
Private Sub TabCtl0_Click()
Page2.SetFocus
End Sub
---------------------
This code will run everytime you click a tab. If you click page 1 or 3 nothing will happen because Text3 is not on those pages. When you click the tab for page 2 the code will run and your macro will run.
The only downside is that everytime you go to page 2 the focus will be set on an 'invisible' control. You cannot set the macro to run on a field because every time you try to type something into the field the macro will run, unless of course your form is intended to be read only?
This is not perfect but it it the best I can think of.
Please let me know if this is ok or not. Or if anyone else has some other ideas I would be interested.
[This message has been edited by Jon.N (edited 05-18-2001).]
[This message has been edited by Jon.N (edited 05-18-2001).]