ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multipage control on Excel VBA forms (https://www.excelbanter.com/excel-programming/284217-multipage-control-excel-vba-forms.html)

James Garner

Multipage control on Excel VBA forms
 
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.



Vasant Nanavati

Multipage control on Excel VBA forms
 
Not very intuitive ...

MultiPage1.Value = 0 'or 1

--

Vasant



"James Garner" wrote in message
...
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.





James Garner

Multipage control on Excel VBA forms
 
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.


"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
Not very intuitive ...

MultiPage1.Value = 0 'or 1

--

Vasant



"James Garner" wrote in message
...
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.








All times are GMT +1. The time now is 01:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com