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