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_Select!cmbo_Make & _
"' And [inv_Model]= '" & Forms!frm_Select!txt_Model & "'"
Exagerated for clarity, that's
SQLstring = "[mke_ID]= ' " & Forms!frm_Select!cmbo_Make & _
" ' And [inv_Model]= ' " & Forms!frm_Select!txt_Model & " ' "
If mke_ID is numeric, you wouldn't need the single quotes:
SQLstring = "[mke_ID]= " & Forms!frm_Select!cmbo_Make & _
" And [inv_Model]= ' " & Forms!frm_Select!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_Select!cmbo_Make & _
" And [inv_Model]= ' " & _
Replace(Forms!frm_Select!txt_Model, " ' ", " ' ' ") & " ' "
(Remember to remove the extraneous spaces when copying that!)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
<mm****@gmail.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.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_Click
Dim stDocName As String
Dim SQLstring As Variant
SQLstring = "'" & "[mke_ID]= " & Forms!frm_Select!cmbo_Make & "'
And '" & "[inv_Model]= " & Forms!frm_Select!txt_Model & "'"
MsgBox (SQLstring)
stDocName = "rpt_Inv-COST"
DoCmd.OpenReport stDocName, acPreview, , SQLstring
Exit_Command7_Click:
Exit Sub
Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click
End Sub