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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
"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
|
|||
|
|||
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
|
|||
|
|||
|
Thread Tools | |
Display Modes | |
|
|
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 |
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 |