second combo list based on first combo

  • Thread starter Thread starter David B
  • Start date Start date
D

David B

I'm getting really frustrated trying to do what I'm sure is totally easy:

I have a table that contains, among other fields, Company and Employees. I
need a form with two combo boxes, the first one to select the company, and
the second to select the employees based on the selection in the first box.

The first is bound to the Company field and brings up the list OK, but I
cannot get the second to select anything but the entire list of Employees
rather than the employees for the selected company. I know this is SO easy,
but I'm frustrated enough to ask for help at this point.

TIA,
David
 
Dave,

Here's a simple example...

Private Sub FirstCombo_AfterUpdate()

Dim st As String

'assumes that the bound column of FirstCombo is a number

st = "SELECT tblEmployees.EmployeeID, tblEmployees.Employee, " & _
"tblEmployees.CompanyID FROM tblEmployees " & _
"WHERE (((tblEmployees.CompanyID)=" & Me.FirstCombo & ")) " & _
"ORDER BY tblEmployees.Employee;"

With Me.SecondCombo
.RowSourceType = "Table/Query"
.RowSource = st
.ColumnWidths = "0 cm; 3 cm; 0 cm"
End With

End Sub

HTH,
Jeff
 
AWESOME! Thanks, I was wondering if I could use a Transact-SQL type query in
the code, and now I know!

Thanks,
David
 
Back
Top