Conditional Visability based on combo box selection

pixelpusher

New member
Local time
Today, 12:43
Joined
Dec 20, 2006
Messages
8
I'm not new to object oriented programming but I am new to Access. I have found some questions similar to mine in search but I need more explanation if someone wouldn't mind.

In my form, I have a combo box that looks up 3 values from another table. Among other controls, I have a few text boxes that I only want visible if 1 of the 3 possible combo box options are selected.

I understand that the code for this should probably be placed in the "events" of the of the combo box...which one? I understand the logic but what would the code look like? Do I use the expression builder?

Thanks for any help on this.
 
Assuming your limiting the combo box to whatever is already in the combo box -- the user can't type new information into the combo box, which is the default -- then use the OnChange event. It would look something like this:

Code:
Private Sub YourComboBoxName_Change()

    Select Case YourComboBoxName
        Case 1
            YourControlName1.Visible = True
            YourControlName2.Visible = True
            YourControlName3.Visible = True
        Case 2
            YourControlName1.Visible = False
            YourControlName2.Visible = False
            YourControlName3.Visible = False
        Case 3
            YourControlName1.Visible = True
            YourControlName2.Visible = True
            YourControlName3.Visible = True
        Case Else
    End Select

End Sub

You would use the Code Builder to get here.

If you're allowing the user to type new things into the combo box, then use the AfterUpdate event instead as the OnChange event would run everytime they typed in a new character.

~Moniker
 
Last edited:

Users who are viewing this thread

Back
Top Bottom