New number based on LastId

ailyn

Registered User.
Local time
Today, 15:06
Joined
Sep 16, 2005
Messages
31
Hi I have a couple of tables that should have an automathed value.
What I need is to get the last RecordId from the table from where we get the last RecordNr and insert the next value (RecordNr) in a new record.
I tried to do this autom. in the table by making the RecordNr a numeric Value with a mask for 000 numbers and a +1 as a standard value but it doesn't work.
What can I do? Should it be a function/query?
 
You can't do it in the table unless you add an autonumber field. You can do it with some VBA whichj you can implement in a form. DMax() will find the largest value in the field and you can add one to that to give you the next number.
 
Thanks Neileg. I searched for it and made this one:
Code:
    Dim RecordNew As String
    RecordNew = 1 + Nz(DMax("[RecordNr]", "[TblRecords]"), 0)
    Me.RecordNr.Value = RecordNew
 

Users who are viewing this thread

Back
Top Bottom