Solved Show Last Record in Query by Date

theinviter

Registered User.
Local time
Today, 00:06
Joined
Aug 14, 2014
Messages
273
Dears;
Need help,
How to filter the query to show only last record by date, as the filed name DATE_.

thanks
 
you create another query (qry1) that will retrieve PK number and the Max of date:

select [PK field], Max([yourDateField]) As MaxOfDate from yourTable;

now join this qry to your Original query and join them on the two fields.
 
Can be done 1 query.
Code:
SELECT TOP 1 * FROM YourTable ORDER BY DATE_ DESC

Even arnelgp's solution can be done In one query using a sub-query.
 
Even arnelgp's solution can be done In one query using a sub-query
your query will return only 1 record?
what if there are many PKs/Date on the table?
 
your query will return only 1 record?
what if there are many PKs/Date on the table?
Then only one record will be shown.
The wish was "only last record by date". So 1 record.

Edit: If the time parts of a same date differ, your query will also select 1 record.
 
Last edited:
Sorry, but why would you ever name a field "DATE_"? You were right to not use Date because Date is the name of a function and as you probably discovered, you had trouble with a field named Date in VBA. But maybe you could use SaleDate or something more descriptive than a trailing underscore.

Simple is better. Use the Top 1 query.
 

Users who are viewing this thread

Back
Top Bottom