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 
Automatic transaction number
Gregory C. S 
    
9 years ago
The tip below is crude, but it works for me.
On 2/17, I made two posts called "How to increment a number by one."  It was actually how to increase a combination of text and number by one.  For each day, pretend this year's leading text
part is 7362.  Use the technique shared with me posted on 2/17 to separate your number into 3 parts.  7 + middle three and right 4.  Add one to the middle 3 for the day and then add one to the right 4 during the day.  Annoyingly, you will have to manually change your starting point each day unless you can figure out how to ask the system clock for the day of the year.  In my case, I only need to change the left few once per year, but in your case, you could, each day, until you figure out better, add a transaction before others have access to the transactions, overwrite that transaction with a starter number.
If yesterday's transactions was, say, 70401581, then the code would create 70401582. Overwrite that with 70410999.  The first transaction of the day with the autoincrement will be 70411000.  Yearly, manually, do the same thing. Create a new transaction at the end of the year an overwrite.  Suppose the last transaction this year is 73651702.  Overwrite the new record with 8001999.  The first transaction will be 70011000.  Crude but it will work until you find a better way.  Modifying the code I posted on 2/17, you code would look similar to:

DoCmd.GoToRecord , , acNewRec
Dim varResult As Variant
' in DMax(), use the FieldName and the TableName, respectively
varResult = DMax("TranactionNum", "tblTransaction")
' This next part separates (parses) the text from the number part,
' adds 1; then puts the parts back together with leading zeros.
Me.[ TransactionNum] = Left(varResult, 4) & _
Format(Val(Right(varResult, 4)) + 1, "0000")

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: 5/17/2026 11:33:53 AM. PLT: 0s