Page help (1 Viewer)

ian_ok

Registered User.
Local time
Today, 05:48
Joined
May 1, 2001
Messages
90
I have a form with 3 sections/pages (tab controls).

I want to run a macro when the 2nd tab control is clicked, how do I do this.

I've added a macro to on click, but this nothing at all.

Thank you Ian
 

Jon.N

Registered User.
Local time
Today, 05:48
Joined
Nov 24, 2000
Messages
43
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).]
 

ian_ok

Registered User.
Local time
Today, 05:48
Joined
May 1, 2001
Messages
90
Thanks Jon, will update you early next week when I have the time to work on the d/base.

Not sure how I'll do on the code, I can only use macro's at the moment.

Ian
 

ian_ok

Registered User.
Local time
Today, 05:48
Joined
May 1, 2001
Messages
90
Jon I added my macro to (on got focus) for the first tab position field within tab control page 2 and low and behold it works...

I've not fully tested it ie adding info etc, but seems to work.

Thank you.

Ian
 

Jon.N

Registered User.
Local time
Today, 05:48
Joined
Nov 24, 2000
Messages
43
Superb, I'm glad it works for you. Please let me know the final outcome. One thought I have just had, (thinking on the hoof). I have put subforms in a tab page before today. If you can do that you could activate the message box from the OnFocus event of the subform. It might work better because it avoids the need to focus on hidden controls?
 

Users who are viewing this thread

Top Bottom