How do I hide controls until conditions are met?

C

CCB

I have controls that I want hidden until a specific value is selected in a
value list.

There are two values in the value list and depending on which is selected, I
want different controls displayed. What's the best way to accomplish this?
 
R

Rick Brandt

CCB said:
I have controls that I want hidden until a specific value is selected
in a value list.

There are two values in the value list and depending on which is
selected, I want different controls displayed. What's the best way to
accomplish this?

In the AfterUpdate of the (assume you mean a ListBox)...

Select Case Me.ListBoxName
Case "SomeValue"
Me.Control_1.Visible = True
Me.Control_2.Visible = False
Case "SomeOtherValue"
Me.Control_1.Visible = False
Me.Control_2.Visible = True
End Select
 
C

CCB

Sorry I'm so ignorant on this. Can I do this as an expression? Also, where
you have Control_1.Visible, I change this to my field name? Thanks for all
the help so far.
 
B

BruceM

What has been suggested would be an event rather than an expression. To add
the suggested code to the After Update event of the list box, make sure the
form is open in design view, then open the list box's property sheet (right
click the list box and select Properties is one way). Click the Event tab.
Click After Update. An arrow and three dots will appear on the right side of
the After Update line. Click the three dots. Click Code Builder, then OK.
Insert the code between Private Sub (etc.) and End Sub. As has been
mentioned, substitute the actual name of your list box and other details
(such as Case "SomeValue", where instead of "SomeValue" you would but the
actual text from your list box). The code and procedure for adding it would
be the same for a combo box. To add code to the form, right click the square
at the very top left of the form, about where the rulers meet, and select
Properties. Proceed as with the list box.
 
Top