Apologies for title, I am not sure how to phrase it.
I currently have two tables "ASSETS" and "LOANS" ASSETS contains a straightforward list of equipment It has a field "AssetID" which has a One-To-Many relationship with a field in LOANS called "LoanAssetID"
Each piece of equipment can have many loans. It can be loaned to one person, then returned, then loaned to another. There is a field in "LOANS" named "ReturnDate" in which people record the date that a piece of equipment was returned. There is also a field called "StartDate".
A piece of equipment can said to be currently 'on loan' if the most recent record (that with the most recent start date) has no return date.
However, I am not clear enough in my query writing to complete this. I need to find the most recent record as for any asset, there may be multiple return dates, but these may not always correspond to the most recent loan.
Ideally, I would then like this to calculate a field to mark the equipment as 'on loan' 'available' etc.
Thanks for any help in advance
So far I have tried a Max Query, but, probably due to me misunderstanding queries, I am confused as to why it returns more than one result.
So, currently I have tried
SELECT Max(tbl_Loans.[Start Date]) AS [MaxOfStart Date],tbl_Loans [Return Date], tbl_Loans.LoanAssetID
FROM tbl_Loans
GROUP BY tbl_Loans.[Return Date], tbl_Loans.LoanAssetID
HAVING (((tbl_Loans.[Return Date]) Is Null));
However, what I would like is the most recent value only for any given LoanAssetID; what I get is more than one field for each given LoanAssetID where more than one result exists.
Thank you for your help