Access 2007-2019
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
Home   Courses   Seminars   Templates   TechHelp   Fast Tips   Forums   Help   Contact   Join   Order   Logon  
Home > TechHelp > Directory > Access > Sequential Number < Deleted AutoNumber | Customer Codes >
Custom Sequential Number
By Richard Rost   Richard Rost on Twitter Richard Rost on LinkedIn Email Richard Rost   2 years ago

Create Sequential Numbering to Replace OrderID AutoNumbers

 S  M  L  XL  FS  Join Now

In this tutorial you will learn how to create your own custom order number that you can start at whatever value you want and have Access automatically increment the values so you have nice sequential order numbers that have no gaps. 

Timothy asks, "I’m using an AutoNumber for OrderID in my table, like you taught me, but my accountant wants me to have sequential numbers for reporting purposes. What should I do?"


I'll show you how to replace NULL with Order Number values for existing records. We'll talk about problems with multi-user databases and see how to save that new number to the table immediately to avoid conflicts, and we'll learn how to make a Custom Order Number sequence for each Customer, so for example XYZ Company's invoices will be numbered: XYZ-001, XYZ-002, XYZ-003, etc. And of course we'll assign Customer Codes that are unique and alphanumeric.

Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the database template from class plus get access to the Code Vault. If you signed up on YouTube you have to contact me so I can set up your account here on my web site. If you're not a member, Join Today!


If you start off with a table that already has data in it, the code in the video works just fine. However, if you start with an empty table, you'll get an error. The solution:

In the BeforeInsert event, wrap the DMax function inside Nz:

OrderNumber = Nz(DMax("OrderNumber", "OrderT"),0) + 1

That will now set OrderNumber equal to ZERO if there aren't any records.


Learn More

FREE Access Beginner Level 1
Access Level 2 for $1.00

Free Templates

TechHelp Free Templates
Blank Template
Contact Management
Order Entry & Invoicing
More Access Templates


Mailing List - Get Emails When New Videos Released!
Consulting - Need Help with Your Database?


Please feel free to post your questions or comments below or submit them via the TechHelp page.


Question on Extended Cut Video Upload Images   Link  
David Britz 
3 months ago
On the video Create Your Own Custom Sequential Number with DMAX - MEMBERS ONLY EXTENDED CUT, I have a question:

I notice at 34:23, the issue about incrementing the order number unnecessarily. I don't understand why that's happening because OrderNumber is not an autonumber. If you're editing the same order, the highest saved order number should still be 4 (See 35:19), and adding 1 is 5, no?
Richard Rost
3 months ago
I explain why in the video. The previous value is saved in the table even though we're replacing it.
Add a Reply

Show All Comments

Start a NEW Conversation
Only students may post right now. Click here for more information on how you can set up an account. If you are a student, please LOG ON first.

You may want to read these articles from the 599CD News:

1/22/2022Next Appointment
1/18/2022Access B2 Upgrade
1/17/2022Access Beginner 2 Links
1/17/2022Access Beginner 2
1/17/2022New Record on Top
1/13/2022Missing References
1/13/2022Access Beginner 1 Links
1/11/2022Access Fast Tips
1/11/2022System Defaults

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Email Richard
Mailing Address
Phone Number
Fax Number
Course Survey
Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Keywords: TechHelp Access counter Create Your Own Custom Sequential Automatically Incrementing Number with DMAX counter consecutive  PermaLink