Hi Steve
When you make a Wizard you use a UserForm with a MultiPage on it. You then place all controls on each page and then use some code like this to hide all but the first page (page 0)
Private Sub UserForm_Initialize()
Dim i As Integer
For i = 1 To Me.MultiPage1.Pages.Count - 1
Me.MultiPage1.Pages(i).Visible = False
Next
End Sub
Below the Multipage, on the UserForm itself you have your "Next" and "Back" Buttons.
The code for the "Next" button would be like:
Private Sub CommandButton1_Click()
Select Case Me.MultiPage1.Value
Case 0
Me.MultiPage1.Pages(1).Visible = True
Me.MultiPage1.Value = 1
Case 1
Me.MultiPage1.Pages(2).Visible = True
Me.MultiPage1.Value = 1
Case 2
Me.MultiPage1.Pages(3).Visible = True
Me.MultiPage1.Value = 1
End Select
End Sub
you would of course need to add some code to ensure valid entries are made.
Dave
OzGrid Business Applications
Thanks dave, but how about creating textboxes and refedits automatically based on the textbox value from page1.
Thanks steve
Hi Steve
here is an example of how to create an msoObject placed on a UserForm: In this case a TextBox
Private Sub CommandButton1_Click()
Dim tTextBox As MSForms.TextBox
Set tTextBox = Me.Controls.Add("Forms.TextBox.1", "TextBox1", True)
With tTextBox
.Left = 2
.Name = "TextBox1"
.Left = 10
.Top = 10
.Height = 20
.Width = 60
End With
End Sub
...But if you are creating a Wizard you are going about it the hard way. All you need to do is have all Controls and Code on your UserForm and MultiPage and use the Visible property on each control to show or hide.
Dave
OzGrid Business Applications