Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Developers    Comments List
Upload Images | @Reply | Bookmark | Link | Email | Next Unseen |
Duplicate Values in Continuous Form
Michael Duncan 
     
11 hours ago
Hi,

I am trying to prevent the same color from being added to a sub form. Using a combo box of the colors. I tried some VBA code from Richards "Employee Training 11" video. Here is a picture of the code I used. What happens is when I try to add a different color to the sub form the code still shows to message that it is a duplicate.
Michael Duncan OP  @Reply  
     
11 hours ago

Michael Duncan OP  @Reply  
     
11 hours ago
Sorry guys I told you that I got the code from the wrong video. The right video is "Prevent Duplicates"
Donald Blackwell  @Reply  
       
10 hours ago
First, I would try to msgbox Combo22 to see what value is getting sent and ensure it is not in the table already.

Then I would look at where you are using it - in the "before update" event. In Richard's Prevent Duplicates video, he used in the click event, after access had already processed the change. if you move the code to the after update event, it should work but you can't cancel it per se. But after the msgbox you could add something like:

Combo22 = Combo22.OldValue
Combo22.SetFocus
Combo22.Dropdown
Richard Rost  @Reply  
          
10 hours ago
Michael, your screenshot shows DCount checking ColorT for the selected ColorID. If ColorT is your master list of colors, every valid selection already exists there, so it will be flagged even when it hasn't been added to the subform.

The check needs to count records in the table that stores the colors assigned to the current item, matching both that item's ID and the selected ColorID. When editing an existing row, exclude that row from the count. Also, in your BeforeUpdate event, the message alone doesn't stop the selection. Use Cancel = True when a duplicate is found.

What table supplies the subform, and what are its primary key and the field linking it to the main form? That will tell us which table and criteria belong in your DCount.
Michael Duncan OP  @Reply  
     
6 hours ago
ColorSubFormSortQ is the query that supplies the sub form. The primary key is ID and the linked field is PartID.
Add a Reply Upload an Image
Next Unseen

 
 
What's This?

 

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: 11/1/2026 7:29:36 AM. PLT: 1s