Auto numbering for primary key

T

The Chomp

Hello All;
I am designing a database that I want to auto generate a record number. Here
is what I would like to do. Using a Access form when you go to a new record,
I would like the database to auto generate the next record number in
sequesnce. Example:
If the last record number was 43 and I create a new record, the record
number should be 44.
Problem is, I just do not no the code for this.
As I understand it, I do "not" want to use "autonum" feature in Access

Regards
Chomp
 
M

Marshall Barton

The said:
I am designing a database that I want to auto generate a record number. Here
is what I would like to do. Using a Access form when you go to a new record,
I would like the database to auto generate the next record number in
sequesnce. Example:
If the last record number was 43 and I create a new record, the record
number should be 44.
Problem is, I just do not no the code for this.
As I understand it, I do "not" want to use "autonum" feature in Access


Use the form's BeforeUpdate event:

If Me.NewRecord Then
Me.[record number field] = Nz(DMax("[record number
field]", "the table"), 0) + 1
End If
 

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