Multipage control on Excel VBA forms

J

James Garner

Hi guys,

I've been writing a small VBA program in Excel. Part of it involves a form
that asks the user for various inputs. I've used a multipage control to
break the form up into two sections.

The trouble I am having is that once the user presses an OK button, I have a
routine that validates all of the entries to make sure that they make sense
and are consistent with each other. If any aren't, the program displays a
message box and then directs the focus to the offending control. However, if
the control in question is on a different tab to the one that was visible
when the user clicked OK, I can't use the SetFocus method to direct the
focus to it. I think somehow I need to display the tab it is on first and
then set the focus.

So my question is basically, how do I switch between tabs of a multipage
control programatically? I have been through the Excel VBA helpfile which is
not particularly helpful! I have also tried all the obvious combinations I
can think of but without any success.

Would really appreciate any advice anyone could offer.

Regards,

James.
 
J

James Garner

Many thanks, Vasant - that does the job perfectly.

You are right though - it would have taken me a while to guess that was the
way to do it!

Regards,

James.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top