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 Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Autonumbers
Kevin Robertson 

15 years ago
Hi Richard

How can I get the next sequential Autonumber in code.  I tried using Dmax and adding 1 to it which worked great until the last record was deleted, then the wrong number was entered in my ID field (all fields and the form are unbound). Thanks!


Reply from Richard Rost:

I don't believe it's possible to calculate the next AutoNumber. I've never done it before, and I would have to research it for you to be absolutely sure, but AutoNumbers are only meant for INTERNAL Access purposes only. YOU should never really care what they are, except for creating table relationships. Access manages them itself.

You can find out what the largest CURRENT Autonumber is by using DMAX like you said, but let's say you insert 10 records then delete 3. If you DMAX now, you'll get 7, but the next Autonumber will be 11.

I did a quick Google search and most of the forums that I read on a regular basis seem to agree with me. There is the option of COMPACTING your database (which will bring down your Autonumbers to the next highest number) but you'd have to do that EVERY time.

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

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:16:12 AM. PLT: 0s