dbTalk Databases Forums  

Where clause in SQL statement problem

comp.database.ms-access comp.database.ms-access


Discuss Where clause in SQL statement problem in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Giganews
 
Posts: n/a

Default Where clause in SQL statement problem - 02-08-2005 , 11:04 PM






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



Reply With Quote
  #2  
Old   
sfdskf';
 
Posts: n/a

Default Re: Where clause in SQL statement problem - 02-09-2005 , 12:05 AM






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


Giganews wrote:
Quote:
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



Reply With Quote
  #3  
Old   
Marshall Barton
 
Posts: n/a

Default Re: Where clause in SQL statement problem - 02-09-2005 , 12:09 AM



Giganews wrote:

Quote:
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] &
"""")
--
Marsh
MVP [MS Access]


Reply With Quote
  #4  
Old   
Giganews
 
Posts: n/a

Default Re: Where clause in SQL statement problem - 02-10-2005 , 10:42 PM



Thanks for all the help. Problem solved.

Regards,
Mark



"Giganews" <hereinde (AT) yahoo (DOT) com> wrote

Quote:
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




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.