Adding Controls With VBA Code

M

Magness

I am attempting to create multi-page userform for use with surveys. The
general idea is that each tab will house one of the questions and (more
importantly) its possible answers.

Below is my current attempt for the first question. RList is an array
containing a list of names by region and changes depending on values of the
active row when the userform is activated. If there is a way to make the "1"
in "OptionButton1" change with the value of X I think I would have it. (as
written, ObjectButton1 is moved to the end with a caption equal to the last
object in RList)

Private Sub MultiPage1_Change()
Select Case MultiPage1.Value
Case 0
For X = 0 To RList.Count - 1
OptionButton1.Left = 12
OptionButton1.Top = 30 + X * 18
OptionButton1.Caption = RList(X + 1)
Next X
Case 1
...
...
Case Else
Exit Sub
End Select
End Sub

Ideally, I'd like to start with a blank page then create, name, and place
new controls (later portions of the survey will include text boxes and check
boxes) by looping through various arrays like this. Currently I just have
the max possible number of controls and will hide the ones not needed.

Thanks
 
P

Peter T

If I follow

With Me.Controls("OptionButton" & myNum)
..left = 12
' etc
End With

Regards,
Peter T
 

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