INSERT: Multiple Subqueris

cuttsy

The Great Pretender
Local time
Today, 16:10
Joined
Jun 9, 2004
Messages
164
I have a form with a print button. When pressed it runs of a set of labels between 2 dates. I wish to keep a log of the print jobs that are done. Storing the date and time that the print was done, who did it and (The bit I can't figure) the date range of the print job.

I am trying to make an INSERT statement with 2 queries. 1 for the oldest date of the print and one with the most recent date.

Code:
INSERT INTO PrintHistory (RangeStart, RangeEnd)
VALUES (
     (SELECT TOP 1 [Bookings].DateEntered
     FROM [Bookings]
     WHERE [Bookings].ConfirmationSent Is Null
     ORDER BY [Bookings].DateEntered),

     (SELECT TOP 1 [Bookings].DateEntered
     FROM [Bookings]
     WHERE [Bookings].ConfirmationSent Is Null
     ORDER BY [Bookings].DateEntered DESC)
);

The above doesent work and gives 'Reserved Error (-3025)'

Am I barking up the wrong tree with this or have I just made a small error?
 
Try:
SELECT MIN([Bookings].DateEntered) from [Bookings] WHERE [Bookings].ConfirmationSent Is Null
UNION ALL
SELECT MAX([Bookings].DateEntered) from [Bookings] WHERE [Bookings].ConfirmationSent Is Null
 

Users who are viewing this thread

Back
Top Bottom