I'm getting a "data type mismatch in criteria expression" error every time on a form I have set up in my database with cascading comboboxes from two different tables: tblUnits and tblProjects. The first combobox (cboUnit) selects the appropriate UnitID from tblUnits, while the second (cboProject) limits options to ProjectID's to the selected UnitID.
RowSource for cboUnit:
SELECT [tblUnits].ID, [tblUnits].Unit FROM tblUnits ORDER BY [Unit];
And here's the code for the AfterUpdate:
Private Sub cboUnit_AfterUpdate()
On Error Resume Next
cboProject.RowSource = "Select tblProjects.ID " & _
"FROM tblProjects " & _
"WHERE tblProjects.UnitID = '" & cboUnit.Value & _
"ORDER BY tblProjects.ID;"
The ProjectID and UnitID fields in the destination table are numeric but are NOT lookup fields, and the bound columns are correct. I don't understand why I keep getting the criteria mismatch even when dealing strictly with the foreign keys.
ORDER
! Check withdebug.print cboUnit.Value
ifcboUnit
is bound toUnitID
. - BitAccesser