Question : Populate a combo box based on selection from previous combo box

I have a db in Access 2007.  When the user selects a choice from the "reasonForVisitComboBox", I want the next combo box to populate based on the user's selection.  I considered putting something like this in the AfterUpdate Event of the reasonForVisitComboBox:
If Me.reasonForVisitComboBox.Value = "Advising" Then
  Me.empVisitComboBox.RowSource = "Bill";"Jill";"Dan"; etc....

But I would have to do that 8 times for each possible choice.  Is there an easier way to do this?

Answer : Populate a combo box based on selection from previous combo box

Yes. In a table (tblVisitReasons) put two fields:

ReasonsForVisit and Visit. You can make them both character.

Make the source the first dropdown  a distinct query on that table.

Select Disticnt ReasonsForVisit from tblVisitReasons.

Make the source of the second dropdown as follows:

Select Visit from tblVisitReasons Where ReasonsForVisit = Forms!frmMyForm!ReasonForVisitComboBox

In the AfterUpdate event of the first combo box issue a requery on the second combo box.

Sub ReasonsForVisit_AfterEvent()

empVisit.Requery

End Sub


Try that.

E
Random Solutions  
 
programming4us programming4us