By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,491 Members | 1,186 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,491 IT Pros & Developers. It's quick & easy.

Only pull latest entry from a table

P: n/a
I have a table with a Date Field. This field is populated with the
date and time an entry was made to the table.

I am looking to create a query that pulls only the most recent record.
I am pretty sure this is done with the DMax function but I don't know
how to build the code.

Date field is named "Date"
Table is named "ABC"

Can you include the actual code in your response??
Any help is greatly appreciated...

Chris

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rog
Make it a "totals" query (klick on the totals button on the query
design toolbar), which gives you an extra line in the query labeled
Total. Select the date field and select "Max" on the total line. Now
only the last date will appear.

By the way, it's best to rename your field to fldDate or such, Date
refers to today's date if you use it in code.

Nov 13 '05 #2

P: n/a
"Fatz" <cc******@ibtco.com> wrote:
I have a table with a Date Field. This field is populated with the
date and time an entry was made to the table.

I am looking to create a query that pulls only the most recent record.
I am pretty sure this is done with the DMax function but I don't know
how to build the code.


Chris,

You don't need code.

Create a select query and sort the recordset 'descending' on the date
field. This will give the latest record first.

Next, in the query properties, set the 'top values' property to '1'.

Note - if records are 'bulk' updated and therefore contain the same
timestamp then this method will return all of those records.

HTH - Keith.
www.keithwilby.com
Nov 13 '05 #3

P: n/a
"Rog" <de********@state.gov> wrote:
Make it a "totals" query (klick on the totals button on the query
design toolbar), which gives you an extra line in the query labeled
Total. Select the date field and select "Max" on the total line. Now
only the last date will appear.


How would you include other fields using this method?
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.