Dynamic Userform problem...
Alex,
One option is to put (pre-defined) labels and textboxes on your
Page 3 and then use the VISIBLE property to make them visible (or not) as
required, rather than dynamically create them.
Private Sub UserForm_Initialize()
For i = 1 To 3
Me.Controls("Textbox" & i).Visible = False ' <==textboxes are named
Textbox1, textbox2 etc
Next i
End Sub
Private Sub CommandButton1_Click()
For i = 1 To 3
Me.Controls("Textbox" & i).Visible = True
Next i
End Sub
HTH
"Alex" wrote:
Excel helper
I am really struggling with the folowing and cannot seem to get anything to
work, nor find anything if direct relevance on the internet.
I have created a 'Wizard' using a UserForm. My UserForm has 4 pages to the
wizard.
In page 2 is a multi Listbox which shows a part number and description of
that part. There are about 200 in total. Here I ask the user to select the
parts that they want to include in a report which they do so by using the
checkbooxes assigned.
Now for the tough bit. When they click <Next to go to Page 3 I want page 3
to display the parts they they have selected. Specifically I want to create a
label that shows the part number and add a text box where the user enters a
brief description of the destinatioon of the parts.
This set up would be 'dynamic' in the sense that if a user selected 2 parts
than they would see two part numbers and two textboxes on the next page etc.
I cannot work out to dynamically create labels / textboxes etc. I have tried:
Dim myLabel as MSForms.Label
Set myLabel = UserForm1.Cotrols.Add ("Forms.Label.1","mylabel",TRUE)
But this gives an error.
Any suggestions from here?
Infact I cannot work out how to use VBA to create labels etc on a UserForm
without doing it manually...
Thanks
Alex
|