Cascading Combo Box Troubleshooting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello. I know that the answer is out there but I've spent almost two hours
looking for it without succes. So, I'm hoping someone here will be kind
enough to offer some advice.

I want the standard: pick something in combo box 1, combo box 2 fills in.

This is my code:

Private Sub DepartmentId_AfterUpdate()

Me.Director.RowSource = "SELECT [Director] FROM tblDepartments WHERE
[Department]= " & Me.DepartmentId & ""
Me.Director.Requery

End Sub

However, I get nothing in combo box 2.

What's wrong with this? Please help. Thx.
 
saguilar,

if department is a numeric datatype, then the following should work:

Me.Director.RowSource = "SELECT [Director] FROM tblDepartments " & _
"WHERE [Department]=" & Me.DepartmentId

if it's text, then you'll need addtional punctuation

Me.Director.RowSource = "SELECT [Director] FROM tblDepartments " & _
"WHERE [Department]='" & Me.DepartmentId & "'"

or

Me.Director.RowSource = "SELECT [Director] FROM tblDepartments " & _
"WHERE [Department]=""" & Me.DepartmentId & """"

Brian
 
Back
Top