473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Access 2000 adds brackets [] to queries

Hi all,
Does anyone have any bright ideas for Access' tendency to add square
brackets when it parses queries, then tell you that the query syntax is
invalid. In my case, I'm trying to do a LEFT JOIN on a subquery, like so:

SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN (SELECT [Marker-Label] FROM targetMarkers
WHERE targetID = Forms!frmTargetDetails ) as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));

When I save the above query it gets parsed and saved as:

SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN [SELECT [Marker-Label] FROM targetMarkers
WHERE targetID = Forms!frmTargetDetails ]. as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));
or worse, it inserts the square brackets into the middle of the
subquery, like
[SELECT [Marker-Label] FROM targetMarkers WHERE targetID =
Forms]!frmTargetDetails )
If the query is saved as a QueryDef, Access seems to run the compiled
query and the misplaced text doesn't matter. However, if the original
SQL is used as the RowSource of a ComboBox, the combo box always given
an error OnEnter.
Is there a way to prevent Access from adding these erroneous square
brackets?

Thanks,

Eric
Nov 13 '05 #1
3 3322
On Jun 07 2004, 12:07 pm, Eric Ellsworth <e@e> wrote in
news:sZ********************@speakeasy.net:
Does anyone have any bright ideas for Access' tendency to add
square
brackets when it parses queries, then tell you that the query syntax
is invalid. In my case, I'm trying to do a LEFT JOIN on a subquery,
like so:

SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN (SELECT [Marker-Label] FROM
targetMarkers WHERE targetID = Forms!frmTargetDetails ) as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));

When I save the above query it gets parsed and saved as:

SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN [SELECT [Marker-Label] FROM
targetMarkers WHERE targetID = Forms!frmTargetDetails ]. as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));

<snip>

Is there a way to prevent Access from adding these erroneous square
brackets?


Access uses the undocumented [SELECT ... ]. AS syntax to support derived
tables in Jet SQL. While Jet itself is usually ok with that syntax, the
Access query editor gets thoroughly confused when it sees that syntax and
other square brackets in the same SQL string. Unlike Jet 3.5, Jet 4
supports the standard (SELECT ...) AS syntax for derived tables, which is
why your SQL compiles fine, but apparently some code behind Access query
editor insists on rewriting the SQL using the old proprietary syntax.

As far as workarounds, you may consider getting rid of hyphens in table and
column names, so that there are no other brackets besides the []. ones to
confuse Access. You may also try to use another variation of the same
undocumented syntax:
`SELECT ...`. AS (backticks instead of square brackets).

--
remove a 9 to reply by email
Nov 13 '05 #2
Eric,
Access does this when table & column names violate ANSI SQL naming rules.
It adds brackets around table & column names so users can cheat and include
spaces & punctuation in table & column names when they shouldn't do that.
What you should do is get in the habit of always typing SQL in caps and
using the underscore (_) character as a wordspace. But you or whomever
built the database didn't do that and now you have brackets. The pain of
renaming every object in the database and fixing every bit of SQL that
references the renamed object may not be worth just putting up with the
presence of the brackets. Without knowing much more about your schema, I'd
suggest leaving things alone.

"Eric Ellsworth" <e@e> wrote in message
news:sZ********************@speakeasy.net...
Hi all,
Does anyone have any bright ideas for Access' tendency to add square
brackets when it parses queries, then tell you that the query syntax is
invalid. In my case, I'm trying to do a LEFT JOIN on a subquery, like so:

SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN (SELECT [Marker-Label] FROM targetMarkers
WHERE targetID = Forms!frmTargetDetails ) as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));

When I save the above query it gets parsed and saved as:

SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN [SELECT [Marker-Label] FROM targetMarkers
WHERE targetID = Forms!frmTargetDetails ]. as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));
or worse, it inserts the square brackets into the middle of the
subquery, like
[SELECT [Marker-Label] FROM targetMarkers WHERE targetID =
Forms]!frmTargetDetails )
If the query is saved as a QueryDef, Access seems to run the compiled
query and the misplaced text doesn't matter. However, if the original
SQL is used as the RowSource of a ComboBox, the combo box always given
an error OnEnter.
Is there a way to prevent Access from adding these erroneous square
brackets?

Thanks,

Eric

Nov 13 '05 #3
Thanks to both of you, Alan and Dimitri.

I will use the backticks, because I believe MySQL, which we are
eventually porting to, supports this syntax. That should solve my
problem nicely.

Again, thanks a lot.

Cheers,

Eric

Dimitri Furman wrote:
On Jun 07 2004, 12:07 pm, Eric Ellsworth <e@e> wrote in
news:sZ********************@speakeasy.net:

Does anyone have any bright ideas for Access' tendency to add
square
brackets when it parses queries, then tell you that the query syntax
is invalid. In my case, I'm trying to do a LEFT JOIN on a subquery,
like so:

SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN (SELECT [Marker-Label] FROM
targetMarkers WHERE targetID = Forms!frmTargetDetails ) as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));

When I save the above query it gets parsed and saved as:

SELECT DISTINCT [Marker-Values].[Marker-Label]
FROM [Marker-Values] LEFT JOIN [SELECT [Marker-Label] FROM
targetMarkers WHERE targetID = Forms!frmTargetDetails ]. as TM
ON [Marker-Values].[Marker-Label] = targetMarkers.[Marker-Label]
WHERE (((targetMarkers.[Marker-Label]) Is Null));


<snip>

Is there a way to prevent Access from adding these erroneous square
brackets?

Access uses the undocumented [SELECT ... ]. AS syntax to support derived
tables in Jet SQL. While Jet itself is usually ok with that syntax, the
Access query editor gets thoroughly confused when it sees that syntax and
other square brackets in the same SQL string. Unlike Jet 3.5, Jet 4
supports the standard (SELECT ...) AS syntax for derived tables, which is
why your SQL compiles fine, but apparently some code behind Access query
editor insists on rewriting the SQL using the old proprietary syntax.

As far as workarounds, you may consider getting rid of hyphens in table and
column names, so that there are no other brackets besides the []. ones to
confuse Access. You may also try to use another variation of the same
undocumented syntax:
`SELECT ...`. AS (backticks instead of square brackets).

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: jason | last post by:
Hi Ray...a while ago you explained an elegant solution to enable me to CREATE and EDIT existing tables and queries inside my online access 2000 database.... could you provide refresher links on...
1
by: Jatin | last post by:
Hi, I have developed an application using VB 6 (SP 5), MS Access 2000 and Crystal Reports 9. I migrated from from access to SQl Server 2000. This wasn't a problem as i could import all the...
1
by: Frank | last post by:
Aloha, I have a DB in Access 2000 consisting of about 1500 lines of code and 65 tables, 95 queries and 60 forms and want to "merge" with another persons program written in Access 2 with about the...
2
by: Galina | last post by:
Hello I already initiated a thread with the same name on 22/03/2004. Thank you everyone who answered me. I wanted to link to that thread, but somehow there was no "Post follow on article"...
3
by: Iain Miller | last post by:
Can anybody help me with some Access 2000 code? I don't do a lot of coding in Access & so every time I come back to do something I pretty much have to relearn the syntax from scratch so this is...
2
by: Dutchy | last post by:
Hi there, After spending several hours trying all I could imagine and search for in Google I gave up. In a continuous form I want to sort the choosen column by clicking the header (label) of...
4
by: ralamo | last post by:
I've written a query in a notepad. I want to test whether it works or not. I don't find any option to run user written queries in in Ms-Access 2000. When i ckick on 'Queries' tab, it gives option...
2
by: ILCSP | last post by:
Hello, I'm in the process of changing our 'normal' Access 2000 update queries to Update Pass Through Queries. We have a SQL server 2000 database and we're using an Access 2000 database as our...
4
by: ThePhenix | last post by:
Hi everybody, I have recently been doing a conversion for my boss for a access 2000 database (both front and backend) to a MSSQL backend. I finished the conversion today (as quite a lot of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.