Solved

Reserved word in SELECT statement

Posted on 2011-09-16
18
453 Views
Last Modified: 2012-05-12
CurrentDb.Execute "SELECT ZONE.CITY as ORIGIN_CITY ZONE.PROVINCE as ORIGIN_PROVINCE ZONE.CPCOMBO, ZONE.[ROUTING TERMINAL], ZONE.TCOMBI, ZONE.[ZONE], ZONE.[MIN], ZONE.[LTL], ZONE.[500], ZONE.[1M], ZONE.[2M], ZONE.[5M], ZONE.[10M], ZONE.[20M] INTO getOriginBeyond FROM [ZONE] WHERE ZONE.CPCOMBO=" & Chr(34) & cpccombo & Chr(34) & " AND ZONE.[ZONE]=" & Chr(34) & "BEYOND" & Chr(34), dbFailOnError

Open in new window


Hi,

I am getting Error3141: The select statement includes a reserved word or an argument name...

I tried breaking my head over 30 mins on this. No clue where there is a reserved word is being used. I already put "[ ]" over reserved words such as "Min" and such.

Any help is much appreciated!

Thanks!
0
Comment
Question by:Shanan212
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
18 Comments
 
LVL 11

Assisted Solution

by:datAdrenaline
datAdrenaline earned 100 total points
ID: 36551819
ZONE is a reserved word for the ACE/Jet database engine.

http://office.microsoft.com/en-us/access-help/access-2007-reserved-words-and-symbols-HA010030643.aspx

Check out the section titled "Access database engine reserved words"
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 400 total points
ID: 36551820

SELECT ZONE.CITY as ORIGIN_CITY,  ZONE.PROVINCE as ORIGIN_PROVINCE ZONE.CPCOMBO,
  looks like a comma was missing   ^^^
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 36551834
Just in case you are not using the JET database engine, here is the list for Jet 4.0:
http://support.microsoft.com/kb/321266
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 75
ID: 36551837
Amazing also that ZONE is a Reserved Word ... but I doubt that is the problem.


SELECT ZONE.CITY as ORIGIN_CITY, ZONE.PROVINCE as ORIGIN_PROVINCE ZONE.CPCOMBO,
    ZONE.[ROUTING TERMINAL],
    ZONE.TCOMBI,
    ZONE.[ZONE],
    ZONE.[MIN],
    ZONE.[LTL],
    ZONE.[500],
    ZONE.[1M],
    ZONE.[2M],
    ZONE.[5M],
    ZONE.[10M],
    ZONE.[20M]

INTO getOriginBeyond

FROM [ZONE]

WHERE ZONE.CPCOMBO=" & Chr(34) & cpccombo & Chr(34) & "
        AND ZONE.[ZONE]=" & Chr(34) & "BEYOND" & Chr(34),
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 36551872
Another comment ...

... CurrentDb.Execute can't be used for a SELECT statement.  Use CurrentDb.OpenRecordset
0
 
LVL 75
ID: 36551878
>>  INTO getOriginBeyond

Easy to miss ...

mx
0
 
LVL 75
ID: 36551885
OP has posted a couple of times already ... and the INTO seems easy to miss ... but it's not a Select query.

mx
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 36551899
Sorry ... I missed the INTO keyword :-s ... so .Execute is good :) ...

In this case, I would likely alias the ZONE source, and drop the source qualifier for your fields since you don't really need that when you have a singular source.

SELECT CITY as ORIGIN_CITY,
    PROVINCE as ORIGIN_PROVINCE,
    CPCOMBO,
    [ROUTING TERMINAL],
    TCOMBI,
    [ZONE],
    [MIN],
    [LTL],
    [500],
    [1M],
    [2M],
    [5M],
    [10M],
    [20M]

INTO getOriginBeyond

FROM [ZONE] As aZone

WHERE CPCOMBO="somestring"
        AND [ZONE]="BEYOND"

{note: that above is a sample of the resolved SQL statement after the concatenation expression}
0
 
LVL 75
ID: 36551932
I'm pretty sure the missing comma is the issue ..

SELECT ZONE.CITY as ORIGIN_CITY   ZONE.PROVINCE as ORIGIN_PROVINCE ZONE.CPCOMBO, ZONE.
no comma here .................................^^
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 36551940
Mx ... yes I caught the INTO from your second post (36551837) :) ... I failed to scroll horizontally  :-s
0
 
LVL 75
ID: 36551945
I HATE the code window for that reason ... No Word Wrap.  Hello !!!!!!

mx
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 36551958
Mx,

I would think the error would be different if the comma was the issue, maybe 'Missing Operator" or something like that.
0
 
LVL 75
ID: 36551967
Well ... the missing comma is just before ZONE ... who knows ....?

mx
0
 
LVL 13

Author Closing Comment

by:Shanan212
ID: 36551988
It worked. Comma is the problem. I've used this before for different query and it worked fine which is what made me go crazy :/

Thanks all!

Have a great weekend!
0
 
LVL 75
ID: 36552004
Yeah ... somehow ... the missing comma got wrapped into the ZONE reserved gig ... go figure.

mx
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 36552006
True ... AND ... I just created a Table object named Zone with a Field named Zone and did a SELECT .. INTO with CurrentDb.Execute {and made no provisions for treating Zone as a reserved word} in the hopes of duplicating the error message ... but nope ... all worked just fine when running from VBA  (A2010/64bit).

.. So .. by adding the comma and treating Zone as a reserved word will hopefully solve the issue for the OP.
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 36552016
Cool! ... Glad you got it sorted! ... amazing how things manifest themselves!
0
 
LVL 75
ID: 36552024
In general, I think the Reserved Word gig is a bit overrated ... at least in SQL ... ie, doesn't seem to cause that many problems per se.

mx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question