You want to group by the pilot (or aircraft?) and the date, and sum the
flying hours for that date and the previous date?
The query will look something like this:
SELECT tblFlight.PilotID,
tblFlight.FlightDate,
(SELECT Sum(Dupe.FlightTime) AS SumOfFlightTime
FROM tblFlight AS Dupe
WHERE (Dupe.PilotID = tblFlight.PilotID)
AND (Dupe.FlightDate Between tblFlight.FlightDate -1 And
tblFlight.FlightDate))
AS TwoDayFlightTime
FROM tblFlight
GROUP BY tblFlight.PilotID, tblFlight.FlightDate;
The 3rd field is a subquery, so the results will be read-only. If subqueries
are new, here is Microsoft's introduction:
How to Create and Use Subqueries
at:
http://support.microsoft.com/?id=209066
Note that "Date" is not a good choice of field name: it will probably work
okay here, but in some contexts Access will misunderstand it as the system
date. Hence "FlightDate" in the example above.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Wazza580 said:
I need to be able to create a total from 2 fields, [Date] and [FlightTime].
The 2 day total is the sum of the [FlightTime] for [Date] and [FlightTime]
for [Date]-1 (previous day).