I'm still working on my first database project, and have learned so much during this process. Now I'm stuck at what seems to me, a simple query, but how to do this escapes me.
I have created a database (with SSnafu's help, that is!) that tracks assets (aircards, in this case), when they're checked out and back in, and to whom.
Here are the things I want the query to do:
1. Given an inventory number of an aircard (aircards.inventory_number),
2. Find the records for aircard actions (action_list.action_list) that begin with "check*" (this covers records that are "checked out to" and "checked in to"
3. AND returns the ONE record with the max date (aircard_actions.action_date) from #2.
Overall, what I want is the userid (employees.userid) that was the most recent person a card was checked in/out to, so I can display it in a read-only box on the form with the other aircard data. This way when going through the aircards, you can see instantly who it belongs to at the present time.
The query I've made will drill down somewhat, but I cannot seem to get it to show ONLY the latest date. And for this instance, I've hard-coded the criteria of "m100" as the inventory number so I'm only looking at 1 card. That would be removed later. Here's what it looks like:

Or, the code:
Code:
SELECT Aircards.inventory_number, action_list.action_list, Aircard_Actions.action_date, Employees.userid
FROM Employees INNER JOIN (action_list INNER JOIN (Aircards INNER JOIN Aircard_Actions ON Aircards.Aircard_PK = Aircard_Actions.AircardId_FK) ON action_list.ActionID_PK = Aircard_Actions.action_FK) ON Employees.EmployeeId_PK = Aircard_Actions.UserID_FK
GROUP BY Aircards.inventory_number, action_list.action_list, Aircard_Actions.action_date, Employees.userid
HAVING (((Aircards.inventory_number)="m100") AND ((action_list.action_list) Like ("che*")));
And this gives me exactly what I want it to, but I only want the MAX date, 1 record, and I'm getting all the records. I've tried using MAX(date) everywhere, but I always get an aggregate error or operand error. This is what I get presently with this code:

So, can anyone tell me how to get the ONE record from the above picture and where or what I would use "max(date)" or if there's something else I should know about. I would appreciate it greatly!
Regards,
Mike