Although I've managed my way around the problem with some code, I am curious about what the problem is with the following.
I'm attempting to INSERT INTO a table with the following SQL
The UNION runs fine when run as a select query but when I use the same union statement as the source for an "INSERT INTO" it complains that it's an invalid UNION query ... and highlights the word UNION (not very helpful.)
Any ideas or does Access just not allow a Union as the source of an INSERT?
I'm attempting to INSERT INTO a table with the following SQL
Code:
INSERT INTO CompletedOrders ( Code, Description, Quantity, Customer, Phone )
SELECT S.Code,S.Description,S.Quantity, S.Customer, S.Phone
FROM SpecialOrders AS S
Where Datediff("ww",S.[Starting On],#10/25/2004#) Mod S.Weeks=0
AND S.Weeks > 0
AND #10/25/2004# >= S.[Starting On]
UNION ALL
SELECT S.Code, S.Description, S.Quantity, S.Customer, S.Phone
FROM SpecialOrders AS S
Where S.[Starting On] = #10/25/2004#
AND S.Weeks = 0
The UNION runs fine when run as a select query but when I use the same union statement as the source for an "INSERT INTO" it complains that it's an invalid UNION query ... and highlights the word UNION (not very helpful.)
Any ideas or does Access just not allow a Union as the source of an INSERT?