Set Autonumber

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
 
R

Rick Brandt

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.
 
A

Alex H

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
 
R

Rick Brandt

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
 
A

Alex H

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
 

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