Make Combo Box appear/disappear based on another combo box selecti

G

Guest

I am trying to make a combo box appear/disappear on the form based on a
selection criteria on another combo box. Basically if I select criteria A
from combo box 1 then I want combo box 2 to appear. If I select criteria B
from combo box 1 then I do not want combo box 2 to be visible.
 
P

Poindexter

I am trying to make a combo box appear/disappear on the form based on a
selection criteria on another combo box. Basically if I select criteria A
from combo box 1 then I want combo box 2 to appear. If I select criteria B
from combo box 1 then I do not want combo box 2 to be visible.

I would do something like this:

First, establish your second combobox is invisible by going to it's
properties and entering in Default Value:

Me.SecondComboBox.Visible = False


Thenk, Go to "Properties" of your first combobox and click to the
right of the white box 'After Update'.
Click the '...' button
Select "Code Builder"

Private Sub ComparisonSort_AfterUpdate()
If Me.FirstComboBox = "Valueyouwant" Then Me.SecondComboBox.Visible =
True Else Me.SecondComboBox.Visible = False

End Sub


That should at least get you in the right direction.
 
P

Poindexter

I would do something like this:

First, establish your second combobox is invisible by going to it's
properties and entering in Default Value:

Me.SecondComboBox.Visible = False

Thenk, Go to "Properties" of your first combobox and click to the
right of the white box 'After Update'.
Click the '...' button
Select "Code Builder"

Private Sub FirstComboBox_AfterUpdate()
If Me.FirstComboBox = "Valueyouwant" Then Me.SecondComboBox.Visible =
True Else Me.SecondComboBox.Visible = False

End Sub

That should at least get you in the right direction.
 
G

Guest

Thanks for the reply....however if I choose an option that makes the combo
box visible, and I then go to a new record...the combo box that is suppose to
be invisible is still visible. I have the properties set for visible = No.
Everything seems to be working correctly except for the fact that when I
choose a new record those invisible combo boxes are not invisible if I choose
something in them in the record before.
 
P

Poindexter

That's what the 'Else' Statement is for:

If Me.FirstComboBox = "Valueyouwant" Then Me.SecondComboBox.Visible =
True Else Me.SecondComboBox.Visible = False

If the value of what you want is shown in the first combo box, the
second one appears. When you change the value to something you don't
want, the second combo box disappears.
 

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

Similar Threads


Top