Your single single quotes are wrong. Assuming both mke_ID and inv_Model are
text fields, the quotes need to go around the value being passed, not the
field names:
SQLstring = "[mke_ID]= '" & Forms!frm_Selec t!cmbo_Make & _
"' And [inv_Model]= '" & Forms!frm_Selec t!txt_Model & "'"
Exagerated for clarity, that's
SQLstring = "[mke_ID]= ' " & Forms!frm_Selec t!cmbo_Make & _
" ' And [inv_Model]= ' " & Forms!frm_Selec t!txt_Model & " ' "
If mke_ID is numeric, you wouldn't need the single quotes:
SQLstring = "[mke_ID]= " & Forms!frm_Selec t!cmbo_Make & _
" And [inv_Model]= ' " & Forms!frm_Selec t!txt_Model & " ' "
Note, too, that if, for example, txtModel should contain a single quote in
it, you'll need to double up the single quotes in the value using Replace:
SQLstring = "[mke_ID]= " & Forms!frm_Selec t!cmbo_Make & _
" And [inv_Model]= ' " & _
Replace(Forms!f rm_Select!txt_M odel, " ' ", " ' ' ") & " ' "
(Remember to remove the extraneous spaces when copying that!)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
<mm****@gmail.c om> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.com...
The following snipplet produces "Data type mismatch in criteria
expression". It must be someting simple. I will ultimately need this
where condition to contain 3 clauses. I am posting it with 2 thinking
I cna manage to get the 3rd on there with a little help from all of
you. The objective is to open a report based on 3 values supplied in a
form. Lemme know if you need more info. Here is the code and thanks
in advance.....
Private Sub Command7_Click( )
On Error GoTo Err_Command7_Cl ick
Dim stDocName As String
Dim SQLstring As Variant
SQLstring = "'" & "[mke_ID]= " & Forms!frm_Selec t!cmbo_Make & "'
And '" & "[inv_Model]= " & Forms!frm_Selec t!txt_Model & "'"
MsgBox (SQLstring)
stDocName = "rpt_Inv-COST"
DoCmd.OpenRepor t stDocName, acPreview, , SQLstring
Exit_Command7_C lick:
Exit Sub
Err_Command7_Cl ick:
MsgBox Err.Description
Resume Exit_Command7_C lick
End Sub