Library code snippets
Access AutoNumber Reset
By Mike Gagne, published on 07 Jun 2003
This is some sample code that shows how to programmatically reset all AutoNumber fields in an Access Database to a correct value (whether it be 0 or the max value + 1). In addition, it contains code for Compacting and Repairing an MS Access Database. This is perfect for people who are working with a complicated Access Database and have experienced AutoNumber bugs!
Related articles
Related discussion
-
Socket Programming in C# - Part 1
by graumanoz (23 replies)
-
Creating a Windows Service in VB.NET
by Templario55 (107 replies)
-
Textbox.databinding.add - Does not write back to Underlying table
by stixoffire (1 replies)
-
Watching Folder Activity in VB.NET
by emmaddai (17 replies)
-
Insert Records From One Ms Access table to Other Access Table
by smithroy9 (7 replies)
Hi only new to access so I am not sure I am doing the right thing.
When I run this I point it to my Database & run it. It goes through everything and completes successfully. But I cannot see any changes.
All my autonumbers are still the same they have not been reset starting from one.
What am I doing wrong or have I got it wrong and this is not what its suppost to do.
Pls let me know.
Tks
When I plug in 2 variables:
UserID = "Admin"
Password = "MYPASSWORD"
I get this error:
"Cannot start application. The workgroup information file is missing or opened exlusively by another user."
The database is not open at all so I don't understand what the problem is.
I am a newbie to this so I'm thinking that I must be making some silly mistake. I was hoping that you wouldn't mind pointing me in the right direction. What am I doing wrong?
PS ... if I disable the password in my db, your application works like a charm.
Thanks in advance.
Dejan
Thank you in advance for your assistance.
The code is part of a Visual Basic project (VB6). It uses an external ADO connection into Access in order to do the autonumber reset. You can do the same thing inside of access by adding a reference to ADO in the Visual Basic editor, then editing the code to work inside an Access module.
I have access database that use autonumber (starting from 1) , I have some number that is missing, how do I reset it?
Sorry, I am not a programmer, so I didn't understand where I should put the code .
Thank you very much
clee
changed a line in your module code:
sExt = Right$(sDestination, Len(sDestination) - InStrRev(sDestination, ".") + 1)
Well Done Mike....just what I needed! Saves re-building the database...whcih was what I'd been told by 'the experts' at our place!
This thread is for discussions of Access AutoNumber Reset.