Display/Hide a Form Control/Field Based On Another Field Value?

P

PowerLifter1450

Hi all, I have to Combo boxes on a form. The first one I would always
like users to see. The second, however, I would like hidden if the
first box has certain values selected. So, if ComboBox1 has values of
1 or 2, I would like ComboBox2 to show as normal. If ComboBox1 has a
value of 3, I would like ComboBox2 hidden. Is there a relatively
simple way of doing this, if at all? Thanks for your help as always!

--Eric
 
G

Guest

You have to take care of 2 things:
(1) When you move from record to record and the combo box contents changes
(2) When the user changes the contents of the combo box

For (1), insert some code in the OnCurrent event for the form
For (2), insert some code in the AfterUpdate event for ComboBox1

Code:
If Me!ComboBox1 = "1" or Me!ComboBox1 = "2" Then
Me!ComboBox2.Visible = True
Else
Me!ComboBox2.Visible = False
EndIf

-Dorian
 
T

tina

add the following code to ComboBox1's AfterUpdate event procedure, AND to
the form's Current event procedure, as

Me!ComboBox2.Visible = Not (Me!ComboBox1 = 3)

hth
 
P

PowerLifter1450

add the following code to ComboBox1's AfterUpdate event procedure, AND to
the form's Current event procedure, as

Me!ComboBox2.Visible = Not (Me!ComboBox1 = 3)

hth







- Show quoted text -

Hi Tina, thanks for the quick response. I inserted a variation of the
code in both place, but now get a run-time error on the After Update
procedure of the combo box that says "Object doesn't support this
property or method." Did I do anything to the code that messed it up?
-->

Me!AcceptStatus.Visible = (Me!AppStatus = "No Application")

Thanks for your help,,

--Eric
 
P

PowerLifter1450

You have to take care of 2 things:
(1) When you move from record to record and the combo box contents changes
(2) When the user changes the contents of the combo box

For (1), insert some code in the OnCurrent event for the form
For (2), insert some code in the AfterUpdate event for ComboBox1

Code:
If Me!ComboBox1 = "1" or Me!ComboBox1 = "2" Then
Me!ComboBox2.Visible = True
Else
Me!ComboBox2.Visible = False
EndIf

-Dorian






- Show quoted text -

Thanks for the help too Dorian. I tried the IF statement, and I get
the "Object doesn't support this property or method" for this line:
Me!AcceptStatus.Visible = True ..... and it probably point to the
false line when the condition is false. Any idea what I did to mess it
up? Thanks,

--Eric
 
G

Guest

Make sure you are using the 'name' of the control (name property) not the
bound field name.

-Dorian
 
T

tina

well, i don't know. does it work when called from the form's Current event?
are AcceptStatus and AppStatus the names of *controls* in the form?

hth
 
P

PowerLifter1450

Make sure you are using the 'name' of the control (name property) not the
bound field name.

-Dorian


Yeah, that helps ! :)

Thanks for your help guys !!

--Eric
 

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

Top