Retrieve only the most recent event and event date

S

Steve

HI. I have a table that consists of an EventID (autonumber, key field),
EventDate (date/time), and EventDescription (memo). I would like to create a
query that returns only the most recent EventDate and EventDescription. When
I use the "max" function for date column only it returns the latest date. But
when I add in the EventDescription, it forces me to use "group-by" for
EventDescription, and the query doesn't work properly. It returns all of the
EventDate(s) and Descriptions. Any assistance would be greatly appreciated.
 
J

John Spencer (MVP)

One method to get the latest Date and Description for every EventID is a query
like the Following.

SELECT EventID, EventDate, EventDescription
FROM YourTable
WHERE EventDate = (SELECT Max(temp.EventDate) FROM YourTable as Temp WHERE
Temp.EventID = YourTable.EventID)

In the query grid of a standard select query against your table:
Field: EventDate
Criteria:=(SELECT Max(temp.EventDate) FROM YourTable as Temp WHERE Temp.EventID
= YourTable.EventID)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top