Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - reset autonumber for new records
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

reset autonumber for new records

 Post Reply Post Reply
Author
Routhg View Drop Down
Newbie
Newbie


Joined: 17 April 2003
Location: United States
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote Routhg Quote  Post ReplyReply Direct Link To This Post Topic: reset autonumber for new records
    Posted: 15 July 2003 at 9:08pm

Hi,

Using Access2000 I have an ID field, an autonumber field, that for some unknown reason went from around 3,000 to 453,054,334 as I tried to append 1200 rows to my table.  even if I delete the 1200 rows, the autonumber internal counter is incremented so the next try starts at (453,054,334 +1200). 

In the access help file there is a method to store a number to the autonumber field, and it worked for one record, but when I tried my append query, the autonumber was back up there in the stratusphere.   I concatenate those ID fields to make a key for another purpose.  Think of it as he-ID|she-ID=couple-ID.  So you can see why it would be impractical for me to concatenate 2 9-digit numbers!

How can I reset the number for the NEXT records, retaining the ID numbers for rows that are already in the table? 

Any help will be GREATLY appreciated.



Edited by Routhg
Back to Top
eksimba View Drop Down
Groupie
Groupie


Joined: 23 April 2003
Location: United States
Status: Offline
Points: 48
Post Options Post Options   Thanks (0) Thanks(0)   Quote eksimba Quote  Post ReplyReply Direct Link To This Post Posted: 15 July 2003 at 11:52pm

The short answer is: you can't.

Access intends for the autonumber field to be a number useful only internally to the database engine as a unique record identifier, but not have any other meaning to the programmer. It is bad Access programming practice to try to use an autonumber field for any other purpose (like concatenation with another field) unless you accept the fact that you have little to no control over the value assigned to the autonumber.

In your situation, as long as you have a field with an autonumber value of 453,xxx,xxx the next autonumber will always be 453,xxx,xxx +1. The only way to reset the values would be to remove the records with the offending autonumber values and then compact/repair the database. In theory, after the compact/repair, the next autonumber value will be the highest existing autonumber value +1.

It would be better for your purposes not to use an autonumber at all, but instead create a small procedure which fires upon creation of a new record and assigns a unique record id. That way you can be assured of having complete control over the numbering system...

- eric
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 16 July 2003 at 7:25am
Originally posted by eksimba eksimba wrote:

 It is bad Access programming practice..

It is bad [insert any database name here] programming practice!

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 16 July 2003 at 8:10am
If the coupleID is so important why not create another table with CoupleID, HeID, and SheID and use the CoupleID reference from that?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.