Userform options

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

Within a userform, can i have a drop down list which when
selected, then shows different further options in the form
of drop down and check boxes depending on the vakue first
entered.

I do not mind if these further options are in another
userform which 'pops up' but am unsure how to get the
dependancy written in.

Thanks

Richard
 
Richard,

The simple answer is yes. You can trap the dropdown click event, and there
you can populate other controls, make them visible/hidden, even create new
ones on the fly.

What exactly do you want to do?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thanks Bob. I need to make options appear depending ont he
selction in the drop down box or tick box. An example is
the number of pieces the unit will come in. The first box
to tick is to say whether it is in more than one piece, so
then i would like a drop down to appear to enter how many.

Similarly (they all run along the same theme), when the
user selects how many units there are going to be, i would
like text boxes to appear, the same number as the number
of untis selected. At the moment i have put in lots of
text boxes in case there are lots of units, but this makes
it a very busy form!

Richard

-----Original Message-----
Richard,

The simple answer is yes. You can trap the dropdown click event, and there
you can populate other controls, make them
visible/hidden, even create new
 
Richard,

Okay, assuming that all of the textboxes are designed onto the form, here is
some sample code

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
ComboBox1.Visible = True
End If
End Sub

Private Sub ComboBox1_Click()
Dim ctl As Control
Dim i As Long

For i = 1 To ComboBox1.ListIndex + 1
Me.Controls("TextBox" & i).Visible = True
Next i

End Sub

Private Sub UserForm_Activate()
Dim ctl As Control

With Me
With ComboBox1
.AddItem "1 Textbox"
.AddItem "2 Textbox"
.AddItem "3 Textbox"
.AddItem "4 Textbox"
.ListIndex = -1
.Visible = False
End With
For Each ctl In .Controls
If TypeName(ctl) = "TextBox" Then
ctl.Visible = False
End If
Next ctl
End With

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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

Back
Top