I attach another DB here, which was written in Access 2000. When you open it in Access XP for the first time, I think you will be presented with two options. Choose "Convert" instead of "Open" and save the database with a new name.
In the new DB, I have changed Amp to text.
(I find that Access 97 and 2000 can do the subtractions even though Amp is text. You can run the original query qryAmpTwo in the new DB to see if it would give you an error in XP because Amp is text.)
Just in case Access XP doesn't like Amp in text, I have used the val() function in this query to convert text Amp to value:
qryAmpDiff TwoRecentDates:-
SELECT First(Date) AS [Date 1], First(Amp) AS [Amp 1],
Last(Date) AS [Date 2], Last(Amp) AS [Amp 2],
iif([Date 1] < [Date 2], Last(val(Amp))-First(val(Amp)), First(val(Amp))-Last(val(Amp))) AS [Difference In Amp]
FROM tblAmp
WHERE Date in (Select Top 2 Date from tblAmp order by Date Desc);
When this query is run, it should return:-
Date 1 ---- Amp 1 -- Date 2 ---- Amp 2 -- Difference In Amp
10/27/02 -- 7.512 -- 10/28/02 -- 10.23 -- 2.718
---------------------------
Field for the Pumps
To incorporate the pumps, I have added a new table with a PumpID field and a parameter query.
tblPumpAmp (in which Amp is text):-
PumpID - Date --------- Amp
P1 ----- 10/6/2002 ---- 11.284
P1 ----- 10/8/2002 ---- 8.261
P1 ----- 10/27/2002 --- 7.512
P1 ----- 10/28/2002 --- 10.23
P2 ----- 11/16/2002 --- 13.256
P2 ----- 11/18/2002 --- 9.223
P2 ----- 11/20/2002 --- 6.111
qryPumpAmpDiff TwoRecentDates:-
SELECT First(PumpID) AS [Pump ID], First(Date) AS [Date 1], First(Amp) AS [Amp 1],
Last(Date) AS [Date 2], Last(Amp) AS [Amp 2],
iif([Date 1] < [Date 2], Last(val(Amp))-First(val(Amp)), First(val(Amp))-Last(val(Amp))) AS [Difference In Amp]
FROM tblPumpAmp
WHERE PumpID=[Enter PumpID] and Date in (Select Top 2 Date from tblPumpAmp where PumpID=[Enter PumpID] order by Date Desc);
When the query is run, the user is asked to enter a PumpID.
If p1 is entered, it should return:-
Pump ID -- Date 1 ---- Amp 1 -- Date 2 ---- Amp 2 - Difference In Amp
P1 ------- 10/27/02 -- 7.512 -- 10/28/02 -- 10.23 -- 2.718
If p2 is entered, it should return:-
Pump ID -- Date 1 ---- Amp 1 -- Date 2 ---- Amp 2 - Difference In Amp
P2 ------- 11/18/02 -- 9.223 -- 11/20/02 -- 6.111 -- -3.112
If Time is recorded in the table similar to Amp, I am sure you can adapt the query for the Time without problem.
Hope this helps.