Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bracketing error in Query

Status
Not open for further replies.

FoxProProgrammer

Programmer
Apr 26, 2002
967
US
PHV helped me combine three queries into a single query yesterday. His suggestion worked great, but when I viewed the SQL in the Query Designer today, I noticed that Access had modified the syntax.

Original SQL:

Code:
SELECT X.*, Y.*, O.*
FROM (SELECT fldlist FROM tblname WHERE somefld = "X") As X
, (SELECT fldlist FROM tblname WHERE somefld = "Y") As Y
, (SELECT otherflds FROM tblname) As O
;

SQL after closing and reopening the Design window. Note the changes in Bold print:

Code:
SELECT X.*, Y.*, O.*
FROM [b][[/b]SELECT fldlist FROM tblname WHERE somefld = "X"[b]].[/b] As X
, [b][[/b]SELECT fldlist FROM tblname WHERE somefld = "Y"[b]].[/b] As Y
, [b][[/b]SELECT otherflds FROM tblname[b]].[/b] As O
;

The really weird thing is that the SQL will run when I first open the Query Builder (even though the SQL has a syntax error), but if I change anything and put it back exactly as before, Access gives me a bracketing error. For example, I inserted an extra space between the first SELECT and "X", then deleted the space, and Access returns the error. I can get rid of the error by editing the SQL to change the [ to ( and deleting the . at the end of each subquery. Does anyone know what is causing this? It is a problem because the user would get this error if they ever open the query and make a change to it, and may not know how to correct it.

Thanks,

dz
dzaccess@yahoo.com
 
I've no idea why it would do this, the [] brackets are normally applied to a field or table name.
Have you tried setting up each sub-select as a query by itself, and rebuild your query selecting from the three new queries? It's not fixing the problem, but it might get you round it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top