|
Question : Ms Access Query using LAST as criteria to find a record not working and bringing RANDOM Restuls
|
|
I run an application using Ms Access. In One of the Queries I used I need to find the last record of the list, in a daily basis I post the last Value of Cash available along with the date, therefore I have a table with the DateID which is an autonumber, date, and CashValue. The problem I am currently having is that I use this query which looks for the LAST record of the Date and the Last Record of CashValue, but now If I run this query randomly is taking a record which is not the last, for Instance right now my last record would be for October 2, and the query shows as result May 23rd, and the CashValue correspondent to May 23rd. I have resolve this issue in the past by copying the data from the table to Excel, then delete the data in the Access Table, then Compact and Repair, and Paste the data back in the Access Table, but It is not working anymore. I checked relationships and they are fine, so I don't know what is going on and why I am having this result. I would like to be able to find a solution to this problem.
|
|
Answer : Ms Access Query using LAST as criteria to find a record not working and bringing RANDOM Restuls
|
|
camilo_gs,
Assuming you have an ID field on that table that is an auto number...
SELECT t1.Fecha, t1.Caja FROM Movimiento_Caja_Dia t1 WHERE t1.[ID] = (SELECT Max(t2.[ID]) FROM Movimiento_Caja_Dia t2)
Regards,
Patrick
|
|
|
|