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 
Append Query DMax Unique Data
Gerald Radack 
      
3 years ago
Trying to run an append query.  One of the fields in the destination table has a unique key (like an account number).  Trying to do a DMax + 1 with the append.  The first one works fine, but subsequent ones don't work because they are then not unique.  Any ideas on a better way to do this
Alex Hedley  @Reply  
           
3 years ago
Unless I'm missing something why would you need to add that field if it's automatically created?
Scott Axton  @Reply  
        
3 years ago
Need to see your code.  
It sounds like you are setting the Account Number (unique key) outside of your append loop instead of as a part of your append loop.
In other words you need to DMax + 1 for each record that you are appending.  Saving as you append a record.
Gerald Radack OP  @Reply  
      
3 years ago
Alex, the field is not automatically created.  I don't know of a way to do something like dmax(("acctno","cust_t")+1) as a Default Value.  That would solve the problem, but Access does not recognize the DMAX statement in a default.  Any idea around that?

As for Scott's inquiry.  There isn't any kind of loop set up.  It is simply an update in mass.
Scott Axton  @Reply  
        
3 years ago
Gerald - -
A regular append query will not work in your case, as you found out.  The DMax + 1 in the criteria field sets all of the records to that value.  It isn't applied for each record.

When the field you are updating is unique (and I'm assuming required??) you have to go at it in a different method.
Do a search of loops.  I see you have Developer 16.  A Record Set loop would be preferable depending how many records you have.
Kevin Yip  @Reply  
     
3 years ago
HI Gerald, DMax+1 can only add one row, because in an append query all rows are added in one go, not one at time -- so DMax+1 can only work for the first row.  DMax has no awareness of each row being added individually, and that's why DMax+1 doesn't work here.  If you want to add N rows with DMax+1, you either have to make N separate append queries, or use VBA to add each row separately.

The ability for a query to process each row individually is called "transactional" ability, and Access doesn't have that.  But SQL Server does.  In SQL Server, an append query can indeed do what you want.
Alex Hedley  @Reply  
           
3 years ago
Alex Hedley  @Reply  
           
3 years ago
Why does it need to be sequential?

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/22/2026 9:05:38 AM. PLT: 0s