Discussion:
Selecting the last 10 records from a specific date
(too old to reply)
semmison
2010-06-03 04:30:33 UTC
Permalink
I have a date field and name field, I want to return the last 10 Name records
entered from a specific date..... ie: Count back 10 records in the date field
from Todays date and display the names from that date, to today.... seems
really simple but I can't get it right...
XPS35
2010-06-03 06:14:40 UTC
Permalink
Post by semmison
I have a date field and name field, I want to return the last 10 Name records
entered from a specific date..... ie: Count back 10 records in the date field
from Todays date and display the names from that date, to today.... seems
really simple but I can't get it right...
You can use TOP in an query. Something like:

SELECT TOP 10 FROM ...... ORDER BY SomeField DESC


But.....

You must be able to sort the entries by a field that tells the order of
entry.
--
Groeten,

Peter
http://access.xps350.com
John Spencer
2010-06-03 12:02:26 UTC
Permalink
A query that would look something like the following.

SELECT TOP 10 NameField, DateField
FROM SomeTable
WHERE DateField <= Date()
ORDER BY DateField DESC

In query design view
== Add the table
== Add the two fields
== Under the DateField enter criteria
<= Date()
== Set the datefield to sort DESCending
== In the query properties, set Top Values to 10

This will return ties for the last position.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
Post by semmison
I have a date field and name field, I want to return the last 10 Name records
entered from a specific date..... ie: Count back 10 records in the date field
from Todays date and display the names from that date, to today.... seems
really simple but I can't get it right...
Loading...