Multipage for a Wizard

S

steve

I have a wizard that is navigated using using buttons like, Back, Next, etc.
I want to show the tab strip so the user knows what steps are next, but I
don't want them to be able to click the tabs themselves to change the page.
I want them to have to use the buttons on the wizard.

If I disable the multipage, then everything's disabled. I thought of using
a public variable and checking if it's true or not, but I'm not sure what
events to use. Please help!

Thanks,
Steve
 
D

Dave Peterson

You can use the .visible property to hide/show pages.

I create a small userform with a multipage control with a few pages. And a
button to advance and another button to retreat.

Option Explicit
Private Sub CommandButton1_Click()
With Me.MultiPage1
If .Value = .Pages.Count - 1 Then
Beep
Else
.Pages(.Value + 1).Visible = True
.Pages(.Value).Visible = False
End If
End With
End Sub
Private Sub CommandButton2_Click()
With Me.MultiPage1
If .Value = 0 Then
Beep
Else
.Pages(.Value - 1).Visible = True
.Pages(.Value).Visible = False
End If
End With
End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long
With Me.MultiPage1
.Value = 0 'first sheet
For iCtr = 1 To .Pages.Count - 1
.Pages(iCtr).Visible = False
Next iCtr
End With
Me.CommandButton1.Caption = "Next"
Me.CommandButton2.Caption = "Prev"
End Sub
 
S

steve

Dave,

Thanks, but that's not exactly what I'm looking for. I want all the tabs to
be visible to the user, I just don't want him to be able to change the page
by selecting a tab. I want to force him to use the Wizard controls on the
form.

thanks,
Steve
 
D

Dave Peterson

Select all the code and then replace .visible with .enabled:

Option Explicit
Private Sub CommandButton1_Click()
With Me.MultiPage1
If .Value = .Pages.Count - 1 Then
Beep
Else
.Pages(.Value + 1).Enabled = True
.Pages(.Value).Enabled = False
End If
End With
End Sub
Private Sub CommandButton2_Click()
With Me.MultiPage1
If .Value = 0 Then
Beep
Else
.Pages(.Value - 1).Enabled = True
.Pages(.Value).Enabled = False
End If
End With
End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long
With Me.MultiPage1
.Value = 0 'first sheet
For iCtr = 1 To .Pages.Count - 1
.Pages(iCtr).Enabled = False
Next iCtr
End With
Me.CommandButton1.Caption = "Next"
Me.CommandButton2.Caption = "Prev"
End Sub


The tabs will be greyed out until you use the buttons to change pages.
 

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