![]() |
Adding Controls With VBA Code
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 |
Adding Controls With VBA Code
If I follow
With Me.Controls("OptionButton" & myNum) ..left = 12 ' etc End With Regards, Peter T "Magness" wrote in message ... 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 |
Adding Controls With VBA Code
Thanks. This will do it. "Peter T" wrote: If I follow With Me.Controls("OptionButton" & myNum) ..left = 12 ' etc End With Regards, Peter T "Magness" wrote in message ... 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 |
All times are GMT +1. The time now is 01:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com