
Dynamic SQL statements with OpenRecordSet function
The single quotes (') you've put around the bulk of the SQL statement are
incorrect. You may need quotes around the value of varTemp, depending on
whether STORE.store is a text field or a number. If a number, the statement
would probably look like this:
SET outSlip = currDbase.OpenRecordSet ( _
"SELECT * FROM STORE WHERE STORE.store = " & varTemp)
If STORE.store is a text field, it would probably look like this:
SET outSlip = currDbase.OpenRecordSet ( _
"SELECT * FROM STORE WHERE STORE.store = " & _
Chr$(34) & varTemp & Chr$(34))
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(to reply via e-mail, remove NOSPAM from address)
Quote:
> hi guys,
> I have statement that looks like this:
> SET outSlip = currDbase.OpenRecordSet ("'SELECT * FROM
> STORE
> WHERE STORE.store =' + varTemp + ")
> varTemp is a variable that is being changed in a for loop
> above. I am just having problems embedding the variable
> into my SQL statement with OpenRecordSet. I am getting
> runtime errors. I tried different combinations on the
> quotations without any effect.
> Any help would be appreciated.
> Thanks
> Adwait