Query Select most recent record (1 Viewer)

mredmond

Registered User.
Local time
Today, 15:01
Joined
Oct 1, 2003
Messages
32
I have two tables, a Master table and a Details table. In the Master is one record per employee. In the Details table are multiple records for each employee. Each Details record is time and date stamped.

If I query the tables, I get all the records from both tables. How do I query the tables so that I get all the records from the Master and the most recent record (based on the time/date stamps) from the Details?

I appreciate any help that comes my way.
 

dcx693

Registered User.
Local time
Today, 16:01
Joined
Apr 30, 2003
Messages
3,265
You can use a totals query where you "Group By" on the field from the master table and use "First", "Last", "Max", or "Min" for the Date field - whichever one works to get you the most recent record (probably "Last").

If you're not sure what a totals query is, take a look at the help topic in Access.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:01
Joined
Feb 19, 2002
Messages
43,371
It's not quite as simple as that. You can either use a sub-select or the two query method I've shown in this post:

http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=44957

Essentially, you need one query to find the "max date" of the record you are interested in and a second to pick up the data fields of that record.
 

mredmond

Registered User.
Local time
Today, 15:01
Joined
Oct 1, 2003
Messages
32
I am always amazed at the depth of expertise out there.

Thanks for your quick and accurate suggestions. Problem solved!
 

Users who are viewing this thread

Top Bottom