A Microsoft Office (Excel, Word) forum. OfficeFrustration

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   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

"Invalid SQL Statement" message from union query



 
 
Thread Tools Display Modes
  #1  
Old April 14th, 2005, 02:51 AM
Alison Downing via AccessMonster.com
external usenet poster
 
Posts: n/a
Default "Invalid SQL Statement" message from union query

Hi there,

I've read the Access help files on union queries and trawled the threads on
the forum but I'm still stuck and hoping someone can help me out. I've
used Access for several years to build small 'text based' DBs but this is
the first time I've really tried to do calculations and totals and this is
all very new to me so please be gentle.

I have two queries ([Invoices] and [Payments], both of which have
calculated fields ([Tax] and [Total] in [Invoices] and [Tax] and [Net] in
[Payments]. I am trying to build a union query which will pull together
the relavant fields from both queries so that I can set some date
parameters in another query and run a summary report.
However, I'm not getting very far as I keep getting an 'invalid SQL
statement' message and I don't understand what I am doing wrong. I am
trying to build the query in simple stages so that I can correct any errors
as I enter them.

What I have so far is;

SELECT [Date],[Net Price]
FROM [InvoiceNetForVATForm]
UNION SELECT [Date],[InvVATCalc]
FROM [InvoiceVATforVATForm]
UNION ALL;

I was expecting the query to return a list of all records on my DB (which
currently only holds about 20 test records) but when I click on 'view' I
get the message "Invalid SQL Statement; expected
'DELETE','INSERT','PROCEDURE','SELECT' or 'UPDATE'"

I'm using Access 2002 if that helps.

Hope someone can help me. Thanks.
Alison
amd[AT]dircon.co.uk

--
Message posted via http://www.accessmonster.com
  #2  
Old April 14th, 2005, 03:24 AM
Duane Hookom
external usenet poster
 
Posts: n/a
Default

Remove the dangling (last) "UNION ALL"

--
Duane Hookom
MS Access MVP


"Alison Downing via AccessMonster.com"
wrote in message news:a74ba9c0045c4e02ae88e76da39cde92@AccessMonste r.com...
Hi there,

I've read the Access help files on union queries and trawled the threads
on
the forum but I'm still stuck and hoping someone can help me out. I've
used Access for several years to build small 'text based' DBs but this is
the first time I've really tried to do calculations and totals and this is
all very new to me so please be gentle.

I have two queries ([Invoices] and [Payments], both of which have
calculated fields ([Tax] and [Total] in [Invoices] and [Tax] and [Net] in
[Payments]. I am trying to build a union query which will pull together
the relavant fields from both queries so that I can set some date
parameters in another query and run a summary report.
However, I'm not getting very far as I keep getting an 'invalid SQL
statement' message and I don't understand what I am doing wrong. I am
trying to build the query in simple stages so that I can correct any
errors
as I enter them.

What I have so far is;

SELECT [Date],[Net Price]
FROM [InvoiceNetForVATForm]
UNION SELECT [Date],[InvVATCalc]
FROM [InvoiceVATforVATForm]
UNION ALL;

I was expecting the query to return a list of all records on my DB (which
currently only holds about 20 test records) but when I click on 'view' I
get the message "Invalid SQL Statement; expected
'DELETE','INSERT','PROCEDURE','SELECT' or 'UPDATE'"

I'm using Access 2002 if that helps.

Hope someone can help me. Thanks.
Alison
amd[AT]dircon.co.uk

--
Message posted via http://www.accessmonster.com



  #3  
Old April 14th, 2005, 10:30 AM
Alison Downing via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

That does it!!
Many Thanks, Duane

--
Message posted via http://www.accessmonster.com
 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Financial Comparison Steven Cheng Setting Up & Running Reports 13 November 26th, 2004 10:59 PM
Executing 'Transform' SQL in VBA Leo General Discussion 20 October 28th, 2004 10:42 AM
Print Taher Setting Up & Running Reports 1 August 31st, 2004 09:07 PM
Access 2000 query SQL statement into VBA code Clint Running & Setting Up Queries 1 June 10th, 2004 01:33 PM


All times are GMT +1. The time now is 01:11 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.