Find the last record on table

  • Thread starter kft10 via AccessMonster.com
  • Start date
K

kft10 via AccessMonster.com

Hi,

I tried to pull out the last record of 'Client_ID' on 'Table1' using Dlast("
[Cliend_ID]","[Table1]") function, but the result is not the client_ID that I
just added on Table1. MS Access show me the client_ID randomly (on the middle
of the record).

Can anyone in this forum tell me why it's happend like that or I might use
the wrong function? Thank you in advance.

Rgds,
KFT
 
M

Marshall Barton

kft10 said:
I tried to pull out the last record of 'Client_ID' on 'Table1' using Dlast("
[Cliend_ID]","[Table1]") function, but the result is not the client_ID that I
just added on Table1. MS Access show me the client_ID randomly (on the middle
of the record).

Can anyone in this forum tell me why it's happend like that or I might use
the wrong function?


DLast has nothing to do with when a record was added. It
selects the value of the field from the last record in the
records as they are retrieved from the query's data source.
If it's a table, it will be a near random record. If it's a
sorted query, then it should be the ;ast record in the sort
order.

With all that in mind, to do what you want, you must have a
field in the table that can be used to determine the order
that records were added. This is commonly done by havin a
field with DefaultValue set to Now().

Once you have that, you can retrieve the last record added
by using:

SELECT TOP 1 *
FROM [table/query]
ORDER BY [date created field] DESC
 

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

Top