Help with code requiring last record

  • Thread starter Thread starter Ayo
  • Start date Start date
A

Ayo

I am trying to perform an action based on weather the form is on the last
record

If this is the last record in the database then
dosomething ...
End If
 
Define "last".

Do you mean the record that was entered most recently? If so, how will
Access know this? Do you have a "DateOfEntry" date/time field in your
table?

"Last" only makes sense when you sort by something. What are you sorting
by?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Thanks. I guess I can't do what I was attempting to do.

What are you trying to do?You mean in the table, because database means a collection of related
tables and queries organized into a logical

What you call "The Last Row" is potentially a new record, not yet
written.
 
I mean the last record in the database. The blank row after the last row with
data in it.
 
That "blank" row you speak of is not a record, but a visual placeholder for
where to start entering a new record. And, as Jeff has said, records in
Access tables are not stored in any particular order (although it may appear
to be such when you have a form and it LOOKS to you like it is sorting on the
autonumber or such). It really isn't and it won't unless you provide a way
to sort via a query. In fact, when you "open a table" you are really not
actually opening the table but but you are in fact opening a query showing
the data that is stored.

So, if you want to a "last entered" to be available you must include a
date/time field and stamp it when the record is entered. Then, you can be
sure as to which is the last record added.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________
 
I am trying to perform an action based on weather the form is on the last
record

If this is the last record in the database then
dosomething ...
End If

In *CERTAIN CIRCUMSTANCES* - such as the form's Current event - you can use

If Me.NewRecord Then...


John W. Vinson [MVP]
 

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