ldiaz said:
I have a Form and a SubForm,,but when I tried to enter a new record
and it's canceled at middle of the process the AutoNumber in next
record jump to next number,,
example: I open the form to enter a new record..this is 42, then all
process in canceled with Scape key,,the when I open the form again
appear the autonumber = 43 , but 42 was never captured,,
can some help me to correct this..
There is no way to "correct" it, so long as you are using an autonumber
field, because it isn't broken. That's the way autonumbers work.
Autonumbers exist to give a unique key to a record, but you aren't
supposed to rely on their content. There is absolutely no guarantee
that autonumbers will be generated and stored in a consecutive sequence
with no gaps. For that matter, a gap in the sequence would also be
created if you went back after the fact and deleted a record. That gap
wouldn't be filled in by the next record to be created, and you probably
wouldn't want it to be.
If you really care about the content of the field, don't use
autonumbers. Instead, generate your own number, using your own
numbering scheme, in the form's BeforeUpdate event. In a single-user
application, this can be as simple as getting the current DMax() of the
field and adding 1 to it. In a multi-user application, it's usual to
have a "next number" table where you store the next number to be used,
and the process of assigning a number to a record involves opening and
locking that table, getting and incrementing the number, updating the
table, and closing it to release the lock.