dbTalk Databases Forums  

autonumber question

comp.database.ms-access comp.database.ms-access


Discuss autonumber question in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Steve
 
Posts: n/a

Default autonumber question - 04-05-2005 , 01:59 AM






i am experimenting with forms and the add and delete buttons. currently the
pirmary key is a long integer that autoincrements. i am starting off with a
new table with 10 records, when I add a new record, the primary key is
assigned a value of 11. if i delete it then add a new record, it is assigned
12. how can I tell it to use 11? or to calculate it based off the last
greatest value.

so now my keys go from 1-10 and then jump to 26 and start counting there.

Thanks...Steve



Reply With Quote
  #2  
Old   
Ira Solomon
 
Posts: n/a

Default Re: autonumber question - 04-05-2005 , 09:33 AM






Steve:

Sorry.
It can't be done in any simple manner.
If you were desperate you could do as follows.
Copy the table.
Paste, but when asked say structure only.
Write a query that appends the old table to the copy, leaving out the
autonumber field.
The copy will now have continous autonumbers.
You could then delete the original table and rename the copy.

You could write a macro to combine all the above steps. For a small
table this would be practical. For a large table with lots of add and
delete activity, it could be quite slow to run.

Good luck
Ira Solomon

On Tue, 05 Apr 2005 06:59:56 GMT, "Steve" <1@2.com> wrote:

Quote:
i am experimenting with forms and the add and delete buttons. currently the
pirmary key is a long integer that autoincrements. i am starting off with a
new table with 10 records, when I add a new record, the primary key is
assigned a value of 11. if i delete it then add a new record, it is assigned
12. how can I tell it to use 11? or to calculate it based off the last
greatest value.

so now my keys go from 1-10 and then jump to 26 and start counting there.

Thanks...Steve



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.