Queries

  • Thread starter Thread starter jamccarley
  • Start date Start date
J

jamccarley

Is there a way to set up a query to bring up only the last entry in the
database?
 
Sort by whatever field identifies the 'last entry.'

In query design view, open the Properties box.
Looking at the properties of the Query (not of a field), set the Top Values
property to 1.
 
Is there a way to set up a query to bring up only the last entry in the
database?

A *Database* is a container for multiple tables and other objects; do you mean
in a Table?

If so, Access doesn't itself keep track of order entry. You must have a field
(or fields) in the table which would allow you to identify "the last entry".
This might be a sequential Autonumber (if so, don't replicate your database or
it will become random!!) or a Date/Time field with a default value of =Now()
to timestamp each record as it's added. You can use a Top Values query or a
subquery to select the record with the Max of this field to identify the most
recently entered record.
 
Hello,

If you mean in a table, set up a summary query and choose Last for your
summary option. In SQL it looks like this:

SELECT Last(tblTest.FLD_1) AS LastOfFLD_1, Last(tblTest.FLD_2) AS LastOfFLD_2
FROM tblTest;

This is not standard SQL (to my knowledge), so don't expect to use it
ourside of Access. In which Allen or John's suggestions are good.

Clifford Bass
 
If you mean in a table, set up a summary query and choose Last for your
summary option. In SQL it looks like this:

SELECT Last(tblTest.FLD_1) AS LastOfFLD_1, Last(tblTest.FLD_2) AS LastOfFLD_2
FROM tblTest;

Just a warning... Last means "the last record in disk storage order", not "the
most recently added record in the table". They MIGHT be the same, even most of
the time - but you really shouldn't count on it! Compacting or reindexing the
database may rearrange the records and the Last will be First.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top