Union Query

P

pago

Hi everyone,

Can anyone have a look at my union query below, because Access keeps
telling me that I have got a “Syntax Error (missing operator) in query
expression ‘[Account Code]’ = “AAA-071153”


SELECT [Account Code], [Amount], [Transaction Date], [Transaction
description], [Period], [Debit/Credit], [Journal No], [Journal Type],
[Journal Source], [Transaction Reference]
FROM [BAT_1997]
WHERE [Account Code] = “AAA-071153”

UNION SELECT [Account Code], [Amount], [Transaction Date],
[Transaction description], [Period], [Debit/Credit], [Journal No],
[Journal Type], [Journal Source], [Transaction Reference]
FROM [BAT_2007]
WHERE [Account Code] = “AAA-071153”


What is Access trying to tell me?


Many thanks,


Pb
 
J

John Spencer

It looks like you have "smart" quotes in what you have posted.

I don't know if that is the actual case or if they got introduced when you posted.

WHERE [Account Code] = “AAA-071153”
should be
WHERE [Account Code] = "AAA-071153"

If you retyped the query SQL instead of copying and pasting it from the SQL
window, then you are asking us to trouble-shoot your typing and not the SQL of
the query.

John Spencer
Access MVP 2002-2005, 2007-2011
 
P

pago

It looks like you have "smart" quotes in what you have posted.

I don't know if that is the actual case or if they got introduced when you posted.

WHERE [Account Code] = AAA-071153
should be
WHERE [Account Code] = "AAA-071153"

If you retyped the query SQL instead of copying and pasting it from the SQL
window, then you are asking us to trouble-shoot your typing and not the SQL of
the query.

John Spencer
Access MVP 2002-2005, 2007-2011

Hi everyone,
Can anyone have a look at my union query below, because Access keeps
telling me that I have got a Syntax Error (missing operator) in query
expression [Account Code] = AAA-071153
SELECT [Account Code], [Amount],  [Transaction Date], [Transaction
description], [Period], [Debit/Credit], [Journal No],  [Journal Type],
[Journal Source], [Transaction Reference]
       FROM [BAT_1997]
       WHERE [Account Code] = AAA-071153
  UNION SELECT [Account Code], [Amount], [Transaction Date],
[Transaction description], [Period], [Debit/Credit], [Journal No],
[Journal Type], [Journal Source], [Transaction Reference]
        FROM [BAT_2007]
       WHERE [Account Code] = AAA-071153
What is Access trying to tell me?
Many thanks,
Pb- Hide quoted text -

- Show quoted text -


Hi John,

Please excuse my post as I am not a programmer by trade, let anlone an
MVP. Originally I copied and pasted my SQL query from Word to
Access.

The only thing that I changed was the account code but everything
stayed as it is, including the “smarts”.

Just interestingly enough when I copied and pasted the same original
query from Notepad to Access this morning, the same query was accepted
by Access. how strange!

This leads me to think that Word may have applied some formatting that
Access didn’t like.

Correct me if am wrong.


Regards,

Pb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top