Auto Increment a numeric field

G

George King

Is there a way to automatically increment a numeric field when a new record
is created? I want to do this with an existing field, if possible.

For example:
"LogNumber" = 526 in the last record. When a new record is created, I want
"LogNumber" to automatically be entered as 527. The capability of being
edited would be helpful if that's possible. I would like the system to check
the "LogNumber" of the last record, then increment that number by one and
enter the new number into the new record.
 
K

Ken Snell \(MVP\)

You cannot do this in a table, but you can do it in a form that is bound to
the table (or bound to an updatable query that includes that table).

One uses the DMax domain function to get the maximum value for a field, and
then adds 1 to that value:

NextValue = Nz(DMax("FieldName", "TableName"), 0) + 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

Top