Form field visibility dependent on another combo box value

jereece

Registered User.
Local time
Today, 23:03
Joined
Dec 11, 2001
Messages
300
Is there a way I can make a field (combo box or text box) visible on a form only if another combo box on the same form is set to a certain value?

For example, lets say I have a combo box (cboBox1) on a form and it's possible values are "Yes" and "No". I have another combo box (cboBox2) on the same form. I want cboBox2 only visible on the form if cboBox1 is set to "Yes".

Is there a simple way to do this? I appreciate the help.

Jim
 
In the AfterUpdate event of cboBox1, put
Code:
If Me.cboBox1 = "Yes" Then
   Me.cboBox2.Visible = True
Else
   Me.cboBox2.Visible = False
End If

And then you would also want that same code in the form's On Current event so that when you move between existing records cboBox2's visibility will be set to the right value based on cboBox1.
 
Thanks Bob. What if I have several combo boxes that I want to apply this functionality to on the same form? How do I set the form's On Current event since it would involve multiple combo boxes.

Below are two examples;

cboBox1 Yes = cboBox2 Visible
cboBox3 Yes = cboBox4 Visible
cboBox5 Yes = cboBox6 Visible
cboBox7 Yes = cboBox8 Visible

OR

cboBox1 Yes = cboBox2 Visible, cboBox3 Visible, cboBox4 Visible, cboBox5 Visible


Thanks in advance....
Jim
 
The EASIEST way is to type something into the tag property of each of the controls you want to make visible/invisible. Then, in the On Current event you can have:
Code:
Dim ctl As Control

For Each ctl in Me.Controls
   If ctl.Tag = "WhateverYouPutInYourTag" Then
        ctl.Visible = False
   End If
Next ctl
 

Users who are viewing this thread

Back
Top Bottom