missing operator

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Doing the following:
strCode = "8OS"
Set rst3 = dbs.OpenRecordset("SELECT tblProduct.NrOfCases
FROM tblProduct WHERE ((tblProduct.Product_ID)=" & strCode
& ")")

I've got this error message:
"Run-time error '3075'. Syntax error (missing operator) in
query expression '((tblProduct_ID)=8OS)'"

Can anybody advise what's this operator. I cannot figure
it out.

Thanks
 
You need text delimiters in your code. One way

StrCode = Chr(34) & "8OS" & Chr(34)

or use apostrophes to delimit the text.

WHERE ((tblProduct.Product_ID)='" & strCode & "')"
 
Set rst3 = dbs.OpenRecordset("SELECT tblProduct.NrOfCases
FROM tblProduct WHERE ((tblProduct.Product_ID)='" & strCode
& "')")

You need to enclose literal String value (when it is being passed to JET) in
single-quotes or double-quotes.
 
Back
Top