Hiding Labels

M

mickiedevries

I'm using user forms to build a program and I want some radio button
hidden based on what the user selects on a previous form. I know yo
can set the radio button's visible property to false or true on th
form however I'm not sure how to change the visible property based o
what a user selects on a different form. For example my userForm1 ask
a user to select from different options in radio buttons, depending o
the selection UserForm1 sends the user to UserForm2, but also dependin
on the selection I only want certain options in radio buttons t
display so a user can only select further options that directly pertai
to the previous choices.

I know I could use different forms for each selection but I think thi
will make the program overly confusing and I would like to limit m
total user forms by hiding inappropriate choices based on the previou
choices.

Thanks for any help!

Micki
 
B

BrianB

Something like this in userform2:-

Code
-------------------

Private Sub UserForm_Activate()
Me.OptionButton1.Visible = _
IIf(UserForm1.TextBox1.Value = "", False, True)
End Sub

-------------------


To read a value from a userform it has to be live. So in userform1 an
2 you will use something like :-

Code
-------------------

Private Sub CommandButton1_Click()
Me.Hide
UserForm2.Show
End Sub
 
M

mickiedevries

Could you break down this code for me and tell me what each part i
doing (mainly the False True part)? I'm trying to use an option box o
UserForm1 and I'm not sure how to use what you have to accomplis
that.

Private Sub UserForm_Activate()
Me.OptionButton1.Visible = _
IIf(UserForm1.TextBox1.Value = "", False, True)
End Sub

For instance I want to have the optionbutton on UserForm2 not visibl
if the optionbutton on UserForm1 was selected.

Thanks again,

Micki
 
B

BrianB

It is a shorthand version of this - which is what you want :-


Code
-------------------
'- userform 2 code
Private Sub UserForm_Activate()
If UserForm1.OptionButton1.Value = True Then
Me.OptionButton1.Visible = False
Else
Me.OptionButton1.Visible = True
End If
 
Top