missing operator

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
 
J

John Spencer (MVP)

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 & "')"
 
V

Van T. Dinh

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top