Query to display only the last record

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Is it possible to create a query that will only return
the last record in a table?

I want to then assign this query to a macro and print the
record in a report.

I know this may sound simple, but I'm new to this.

Thanks

Brian
 
Brian,

The simple answer to your question is Yes, you can, as long as you have
some way of knowing what the "last" record is. The most reliable way of
doing this is to have a DateCreated field in the table, with its Defauly
Value set to Now() so you always know the most recently added record.
Whichever field you are using to assess "last-ness", you make a query
sorted descending on this field, and then use the Top 1 predicate of the
query... if you are using the query designer, there is a Top Values
combobox on the toolbar, just enter 1 in there. Then you can base your
report directly on this query.
 
Back
Top