Get & display Next autonumber

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a simple way of retrieving the next autonumber (or the highest) to
display in a label.
The field IS in the form. Its from a DAO table
This is to be used to display the number of the next record added in a Add
Record form.
I know MAx(Number) will retrieve it but I don't know how to use it in Code.
Thanks for any help.
 
You say it's in a DAO table - I'm guessing you mean a DAO recordset?

If so (assuming the recordset variable is rst and your autonumber field is
called ID):

rst.Sort = "ID"
Set rst = rst.OpenRecordset
rst.MoveLast
lbl.Caption = rst![ID]
 
Thanks
I ended up using

Me.Label.Caption = "Account Number" & Str(DMax("MyField","MyTable") + 1)
 

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