Where clause in SQL statement problem

G

Giganews

I have an Access 97 database were I am opening a recordset in a module
referencing a control on a form. For some reason when the code executes I am
getting an error message stating missing operator and I am not sure why. The
code is as follows:

Public Sub Module1()
Dim rst as recordset

Set rst = CurrentDb.OpenRecordset("SELECT * From tblStores WHERE
tblStores.[STORENAME] = " & [Forms]![frmStoreForm]![STORENAME] & " ")

[STORENAME] is a text field which is why I delimited it with "

Am I missing something?

Any help would be appreciated.

Regards,
Mark
 
S

sfdskf';

I believe it will work if you add these single quotes as shown:

Set rst = CurrentDb.OpenRecordset("SELECT * From tblStores WHERE
tblStores.[STORENAME] = '" & [Forms]![frmStoreForm]![STORENAME] & "'")

Regards,
Mike Parks
 
M

Marshall Barton

Giganews said:
I have an Access 97 database were I am opening a recordset in a module
referencing a control on a form. For some reason when the code executes I am
getting an error message stating missing operator and I am not sure why. The
code is as follows:

Public Sub Module1()
Dim rst as recordset

Set rst = CurrentDb.OpenRecordset("SELECT * From tblStores WHERE
tblStores.[STORENAME] = " & [Forms]![frmStoreForm]![STORENAME] & " ")

[STORENAME] is a text field which is why I delimited it with "


You didn't delimit it properly:

.. . . ORENAME] = """ & [Forms]![frmStoreForm]![STORENAME] &
"""")
 

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