PC Review


Reply
Thread Tools Rate Thread

Adding Controls With VBA Code

 
 
Magness
Guest
Posts: n/a
 
      2nd Jul 2009

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
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      2nd Jul 2009
If I follow

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

Regards,
Peter T



"Magness" <(E-Mail Removed)> wrote in message
news:3E6C5540-E559-410A-B56F-(E-Mail Removed)...
>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



 
Reply With Quote
 
Magness
Guest
Posts: n/a
 
      6th Jul 2009

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" <(E-Mail Removed)> wrote in message
> news:3E6C5540-E559-410A-B56F-(E-Mail Removed)...
> >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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding web controls from C# code Dariusz Tomoń Microsoft ASP .NET 2 6th Oct 2007 10:34 PM
vs2005 not auto adding controls to code behind Charlie Bear Microsoft C# .NET 4 12th Jul 2007 04:59 PM
Programmatically adding code to existing controls pietlinden@hotmail.com Microsoft Access Form Coding 3 10th Apr 2007 10:46 PM
Adding Controls to a page via external code jwwishart@gmail.com Microsoft ASP .NET 3 29th Mar 2007 02:29 AM
Adding controls to a form with code =?Utf-8?B?TWlrZSBpbiBMLkEu?= Microsoft Access Form Coding 1 1st Mar 2005 07:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:36 AM.