2 comboboxes on a form

  • Thread starter Thread starter geert.van.ransbeeck
  • Start date Start date
G

geert.van.ransbeeck

Hello

I want to have 2 combo boxes on my form.
The first one contains a series of account managers. (No problem; I
used an SQL-statement on the Row source and tere they are).

The second has to contain a list of their clients. So when I select
another account manager in the first combobox, automatically only
their corresponding clients have to disappear in the second combo box.
Can someone help me please how I have to proceed?
 
In the AfterUpdate event of the first combo box, modify the SQL for the
second combo box's RecordSource:

Private Sub Combo1_AfterUpdate()

Me.Combo2.RecordSource = "SELECT Field1, Field2 " & _
"FROM Table2 " & _
"WHERE Field3 = " & Me.Combo1

End Sub

Alternatively, have the RecordSource for the second combo refer to the first
combo:

SELECT Field1, Field2
FROM Table2
WHERE Field3 = Forms!NameOfForm!Combo1

and just requery the second combo in the AfterUpdate event of the first
combo:

Private Sub Combo1_AfterUpdate()

Me.Combo2.Requery

End Sub
 
Back
Top