Search code examples
sqlms-accesscascadingdropdown

datatype mismatch in criteria expression in MS Access


I am creating form in access in which i have to implement cascading combo boxes , data in lower combo box is dependent on its parent value selected by user. Here is form enter image description here

on left side is structure of the table and on right side is form. Problem is I am getting error of data type mismatch , unable to understand why this is happening. In the afterupdate event of Diametre of Drill I am populating cutting speed . Whenever I press drop down of Cutting Speed "Datatype mismatch in criteria expression" occurs. Here is code of afterupdate event of Diametre of Drill

Private Sub cboDiameterDrilling_AfterUpdate()
cboCuttingSpeedDrilling.RowSource = "Select DISTINCT tblDrilling.cuttingSpeed " & _
"FROM tblDrilling " & _
`"WHERE tblDrilling.materials = '" & cboMaterialDrilling.Value & "' AND tblDrilling.diaOfDrill = '` `cboDiameterDrilling.Value ' " & _`
"ORDER BY tblDrilling.cuttingSpeed;"

End Sub

I think problem is in WHERE Clause . Any help would be greatly appreciated. Thank you


Solution

  • You've surrounded the reference to the object's value (cboDiameterDrilling.Value ) in single quotes.

     AND tblDrilling.diaOfDrill = ' & cboDiameterDrilling.Value & "'"  
    

    Solution : AND tblDrilling.diaOfDrill = " & cboDiameterDrilling.Value & " " & _