If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Syntax error (missing operator) in query expression...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Oct 2011
Posts: 5
Exclamation Syntax error (missing operator) in query expression...

Hi All,

I am getting the following MS Access error:

Syntax error (missing operator) in query expression '(((BOQ.Description) =Site Establishment Dismantle))'

For the following VBA statement:

Code:
Dim name As String
name = "Site Establishment Dismantle"
Set rs1 = db1.OpenRecordset("select BOQ.Description from BOQ where " & " (((BOQ.Description) =" & Qu & name & Qu & "))", DB_OPEN_DYNASET)
The statement is in one line.

BOQ is a Table and Description is a Text Field Name.

I would like to select the record in the table that matches name string and then be able to access other field names of that record.

My alternative is using a do loop to search through the entire table...I would like to cut down on this wasted cpu overhead...

I am obviously doing something wrong. Please can anyone help?

Thanks!
Reply With Quote
  #2 (permalink)  
Old
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 12,205
check your bracketing
Code:
Dim name As String
dim strSQL as string
name = "Site Establishment Dismantle"
strSQL = "SELECT Description from BOQ WHERE Description='"  & name & "'"
Set rs1 = db1.OpenRecordset(strSQL, DB_OPEN_DYNASET)
just guessing qu is a variable defiend as ' or ".. you coudl use the CHR function if you prefer

..although why you would want to retrieve the description from the table when you already know the description AND are usign it as the filter in the WHERE clause baffles me
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton

Last edited by healdem; 10-20-11 at 03:48.
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Oct 2011
Posts: 5
Thanks, it passes now, but now I have a new error

Code:
Set rs1 = db1.OpenRecordset("select Description from BOQ where Description ='" & name & "'", DB_OPEN_DYNASET)
MsgBox (rs1!Rate)
Access returns saying "Item not found in this collection." when it executes the last line. The field is there and it is populated in the table...
I have tried it with other Descriptions & field names as well, same error.
Reply With Quote
  #4 (permalink)  
Old
Moderator
 
Join Date: Mar 2009
Posts: 5,175
Your query is:
Code:
select Description from BOQ where...
Which means that Description will be the only column available in the resulting Recordset.

If you want to have the column Rate included in the recordset, it must be present in the SELECT column list of the query (you only receive what you asked for):
Code:
SELECT Description, Rate from BOQ where...
__________________
Have a nice day!
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Oct 2011
Posts: 5
Thank you very much healdem and Sinndho.

My problems are solved. It makes sense now.
Reply With Quote
  #6 (permalink)  
Old
Moderator
 
Join Date: Mar 2009
Posts: 5,175
You're welcome!
__________________
Have a nice day!
Reply With Quote
Reply

Tags
missing operator, select where, syntax error

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On