Auto numbering for primary key

  • Thread starter Thread starter The Chomp
  • Start date Start date
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
 
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
 
Back
Top