Autonumber Increment Event

I have a form that uses an autonumber field.  When a new record is created, the form shows "autonumber" in the field.  Only when I start to enter data in another control on the form, does the autonumber field actually display a value.

I would like to use the autonumber field when I generate a new record to create a Ticket Number (the TicketNo field is a test field that is a concatenation of a couple of fields including the autonumber field).

Does anybody know how I would go about using the autonumber field immediately upon creating a new record in the form?  I have tried adding VB code to the OnClick event for a "New Record" command button to no avail.

Thanks in advance.
SquaredBAsked:
Who is Participating?
 
Steve BinkConnect With a Mentor Commented:
>>> I have a form that uses an autonumber field.  When a new record is created, the form shows
>>> "autonumber" in the field.  Only when I start to enter data in another control on the form,
>>> does the autonumber field actually display a value.

This behavior is by design.  The only way to reserve an autonumber value and populate the control is to begin the edit of a new record.  Just moving to a new record does not trigger the assignment.  I usually use something like an automated timestamp for the original creation of the record.  When the user clicks the button to add new, I put this line of code in the button's OnClick event:

Me!MyTimestampField = Now()

That provides for auditing of when a record was created, and fulfills the requirement of an edited field for the autonumber to populate.
0
 
Steve BinkCommented:
FYI: once an autonumber value is reserved for a new record, it is totally unusable.  If you delete the new record, or otherwise dispose of it, that number will not be reused by Access.  It will not matter if you have saved the record or not...Access increments the seed at the same time it provides a specific value to a new record.
0
 
SquaredBAuthor Commented:
Thanks.  Exactly what I needed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.