Open form to show only last 10 records

I have a form (datasheet) that is bound to a table.  But when the form opens I only want the last 10 records to display.

How can this be done?
SteveL13Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Robert ShermanConnect With a Mentor OwnerCommented:
If you have an autoincrementing ID field, you can probably use TOP

SELECT TOP 10 FROM table ORDER BY ID DESC;

This would, of course, give the last 10 records in reverse order.  You could then use that as a subquery to re-order them, but I believe you might be able to do the re-ordering in a form property.

SELECT * FROM (SELECT TOP 10 FROM table ORDER BY ID DESC;) ORDER BY ID;
0
 
Robert ShermanOwnerCommented:
..and since you mentioned that the form is bound to the table directly, you would just change the datasource of that form to the SQL query.
0
All Courses

From novice to tech pro — start learning today.