Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer 14 Lessons    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Autonumbers
Ray White 
      
6 years ago
Richard what is your thought about using Autonumbers?
Would it not be better to generate your own?
I have done some data recovery before and that autonumber can really give
trouble sometimes, Just your thought?

Auto numbering your items can lead to spaces or 'gaps' being left inside your table. These spaces can never be recovered once they have been created. They are created because auto numbering only guarantees that the number hasn't been used before  they dont guarantee that they are in sequence. Anytime you create a record, but it gets cancelled or deleted, you will end up with a space in your auto numbering field that cannot be deleted or changed.
Alex Hedley  @Reply  
           
6 years ago
Hi Ray, usually your Id column wouldn't be seen by the customer/user, it's something only the DB needs to know about, therefore it wouldn't matter if it skipped a number.
But as Rich mentions in the video if there are times you need it to always exist, like the PaymentTypes it can be better to maintain it yourself.

If you need to increment yourself you can use the Microsoft Access DMax Counter tip.
Richard Rost  @Reply  
          
6 years ago
For the most part I do prefer using autonumbers. Generally they are meant for relationships only and the end user will never have to see them or work with them. If you need a number that the customer may see like a "customer code" then you can create your own, and we're going to be doing that in the POS that we're building. However that's a secondary number and the table will still have an autonumber. The exception is going to be that payment type table that's only going to have a couple of records in it and I want to hard-code things like credit card, cash, etc. in the VBA so I want them to have specific numbers.

As far as data recovery goes, it can be a pain if you lose some records and have to re-enter them and then have to reattach them to related tables. That can be a nightmare. In this case I recommend good backups. But it's nothing that you can't fix with a series of update queries. My general rule of thumb is to never delete information. Unless your database is getting crazy huge you should always just mark things as inactive or not needed. Don't delete orders for example.

As far as worrying about numbers being in sequence that's not something that you should have to worry about. As long as you have a unique number for your relationships that's all that matters. If you need sequential numbers then yes definitely use your own number. You can use DMAX to determine the largest current number, then add one. Save it to the table quickly though so another user doesn't get assigned that number in a multi-user environment.

You can get rid of autonumber gaps at the end of the table if you delete some records at the end. Just compact and repair the database and it will reset the autonumber to the next highest one.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 14 Lessons.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/16/2026 11:21:20 AM. PLT: 1s