Access 2003 Autonumber

A

Autonumber

I have created a form to add a new record to my table. I have a few fields in
the form that are required. When i create a new record, everything works fine
and a new number is assigned to the primary key field. But if i cancel the
record that i am creating before saving it, it says that record can not be
saved as expected. however, when creating next record, primary key increment
number increases by 1 (it adds to the record that i never saved). I cancelled
the last record so it should not have created a record. I can't see that
record in the table or query. When i look at my table it seems like i deleted
some records but i never created those record to start with....What do i need
to do to correct this..
Thanks for your help in advance..
 
G

Gina Whipp

Stop using Autonumber... This is the way Autonumber is suppose to behave.
If you NEED you numbers to be incremental then you need to create your own
Autonumber, example...

Me.YourIDField = DMax("[YourIDField]","[YourTable]") + 1 'Place this on
the Before_Update of the form

Autonumber should only be used when you don't care about the number. I use
behind the scene but what the user sees is the one I generate.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
B

Birk Binnard

You do not have a problem. Access never re-uses a key value. Missing
keys simply show that a previous record using that key is no longer in
the table. Access keeps track internally what the next key value will
be; it does not depend at all on the last/highest key actually in the
table.
 
A

aaron.kempf

there is nothing wrong with autonumber.

if jet can't support autonumber in the way that you would like to use
it-- then you should upsize to SQL Server and get to know triggers.

they are a lot more powerful, and they support multiple users.

Jet was never designed to support multiple users.

-aaron



Stop using Autonumber...  This is the way Autonumber is suppose to behave.
If you NEED you numbers to be incremental then you need to create your own
Autonumber, example...

Me.YourIDField = DMax("[YourIDField]","[YourTable]") + 1    'Place this on
the Before_Update of the form

Autonumber should only be used when you don't care about the number.  Iuse
behind the scene but what the user sees is the one I generate.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm




I have created a form to add a new record to my table. I have a few fields
in
the form that are required. When i create a new record, everything works
fine
and a new number is assigned to the primary key field. But if i cancel the
record that i am creating before saving it, it says that record can notbe
saved as expected. however, when creating next record, primary key
increment
number increases by 1 (it adds to the record that i never saved). I
cancelled
the last record so it should not have created a record. I can't see that
record in the table or query. When i look at my table it seems like i
deleted
some records but i never created those record to start with....What do i
need
to do to correct this..
Thanks for your help in advance..- Hide quoted text -

- Show quoted text -
 
T

Tony Toews [MVP]

they are a lot more powerful, and they support multiple users.

Jet was never designed to support multiple users.

Access and Jet support multiple users just fine.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

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