Set Autonumber

  • Thread starter Thread starter Alex H
  • Start date Start date
A

Alex H

I want to use the autonumber as a serial number, but need it to start at
1005. is this possible please?

Thanks
A
 
Alex said:
I want to use the autonumber as a serial number, but need it to start
at 1005. is this possible please?

Thanks
A

Use an append query to insert a record into th4e table with a value of 1004
and then delete that record afterwards. The next record will then use 1005.

Hopefully you understand that AutoNumbers will not reliably produce a
sequence of numbers without gaps. The general use of AutoNumbers involves
having zero concern for their value other than that they be unique. If you
are counting on anything beyond uniqueness you are likely to be
dissappointed.
 
Thanks for your response - given your caution, what is the best way then to
have a field that will increment by one for each records?

Thanks
A
 
Alex said:
Thanks for your response - given your caution, what is the best way
then to have a field that will increment by one for each records?

Usually in the form used for insertions you use code to assign the number.
The simplest version of this is to use DMax() to determine the highest
existing value and then add 1 to that. As long as you don't have a lot of
users simultaneously entering records doing this in the BeforeUpdate event
of the form works the best.

If Me.NewRecord Then
Me!IDFieldName = Nz(DMax("IDFieldName", "TableName"), 0) + 1
End If
 
Thanks Rick

Alex

Rick Brandt said:
Usually in the form used for insertions you use code to assign the number.
The simplest version of this is to use DMax() to determine the highest
existing value and then add 1 to that. As long as you don't have a lot of
users simultaneously entering records doing this in the BeforeUpdate event
of the form works the best.

If Me.NewRecord Then
Me!IDFieldName = Nz(DMax("IDFieldName", "TableName"), 0) + 1
End If
 
Back
Top