ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MultiPage UserForm (https://www.excelbanter.com/excel-programming/271729-multipage-userform.html)

Michael J. Malinsky

MultiPage UserForm
 
I have a UserForm with a MultiPage control. The MultiPage has 4 pages
(.Value = 0 through 3). Everything works fine until I add another page. I
have a CommandButton on the UserForm that directs the user to the Next
page. When MultiPage.Value = 0, the following code is run:

Select Case MultiPage1.Value
Case 0 ' If Page1 is active...
With MultiPage1
.Value = MultiPage1.Value + 1 ' Move forward 1 page
.Pages(1).Enabled = True ' Enable Page2.
.Pages(0).Enabled = False ' Disable Page1.
End With
CommandButton1.Enabled = True ' Enable Back button.
cbRanges.SetFocus ' Give cbRanges focus.
Case1
Case2
Case3
End Select

When I add a 5th page (MultiPage.Value = 4), and run the code, pressing the
"Next" CommandButton causes MultiPage.Value = 4 rather than 1
(MultiPage1.Value is 0 on Page1, so adding 1 should result in
MultiPage.Value = 1, no?). I am really confused as to why when I add the
5th page, 0 + 1 suddenly equals 4. I could change the index of the pages,
but then the order of the MultiPage would not logically follow the sequence
of events (I know it doesn't matter from a programming perspective, but when
setting this up, I'd like the MultiPage to be in the right order).

TIA
Mike

--
Michael J. Malinsky




Robin Hammond

MultiPage UserForm
 
Sounds weird. You've probably checked this, but do your names for the pages
match the index property for the pages set in the properties window in the
VBE?

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in


"Michael J. Malinsky" wrote in message
...
I have a UserForm with a MultiPage control. The MultiPage has 4 pages
(.Value = 0 through 3). Everything works fine until I add another page.

I
have a CommandButton on the UserForm that directs the user to the Next
page. When MultiPage.Value = 0, the following code is run:

Select Case MultiPage1.Value
Case 0 ' If Page1 is active...
With MultiPage1
.Value = MultiPage1.Value + 1 ' Move forward 1 page
.Pages(1).Enabled = True ' Enable Page2.
.Pages(0).Enabled = False ' Disable Page1.
End With
CommandButton1.Enabled = True ' Enable Back button.
cbRanges.SetFocus ' Give cbRanges focus.
Case1
Case2
Case3
End Select

When I add a 5th page (MultiPage.Value = 4), and run the code, pressing

the
"Next" CommandButton causes MultiPage.Value = 4 rather than 1
(MultiPage1.Value is 0 on Page1, so adding 1 should result in
MultiPage.Value = 1, no?). I am really confused as to why when I add the
5th page, 0 + 1 suddenly equals 4. I could change the index of the pages,
but then the order of the MultiPage would not logically follow the

sequence
of events (I know it doesn't matter from a programming perspective, but

when
setting this up, I'd like the MultiPage to be in the right order).

TIA
Mike

--
Michael J. Malinsky






Michael J. Malinsky

MultiPage UserForm
 
Thanks, but in the beginning of my UserForm_Initialize code, I have disabled
all pages of the MultiPage except Page1. When I added a page and didn't
disable it, Excel apparently decided that going to the next enabled page
(index = 4) rather than the next page in sequence (index = 1, which is
disabled).

Thanks.


--
Michael J. Malinsky


"Robin Hammond" wrote in message
...
Sounds weird. You've probably checked this, but do your names for the

pages
match the index property for the pages set in the properties window in the
VBE?

Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in


"Michael J. Malinsky" wrote in message
...
I have a UserForm with a MultiPage control. The MultiPage has 4 pages
(.Value = 0 through 3). Everything works fine until I add another page.

I
have a CommandButton on the UserForm that directs the user to the Next
page. When MultiPage.Value = 0, the following code is run:

Select Case MultiPage1.Value
Case 0 ' If Page1 is active...
With MultiPage1
.Value = MultiPage1.Value + 1 ' Move forward 1 page
.Pages(1).Enabled = True ' Enable Page2.
.Pages(0).Enabled = False ' Disable Page1.
End With
CommandButton1.Enabled = True ' Enable Back button.
cbRanges.SetFocus ' Give cbRanges focus.
Case1
Case2
Case3
End Select

When I add a 5th page (MultiPage.Value = 4), and run the code, pressing

the
"Next" CommandButton causes MultiPage.Value = 4 rather than 1
(MultiPage1.Value is 0 on Page1, so adding 1 should result in
MultiPage.Value = 1, no?). I am really confused as to why when I add

the
5th page, 0 + 1 suddenly equals 4. I could change the index of the

pages,
but then the order of the MultiPage would not logically follow the

sequence
of events (I know it doesn't matter from a programming perspective, but

when
setting this up, I'd like the MultiPage to be in the right order).

TIA
Mike

--
Michael J. Malinsky









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

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