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 
VBA Code
Paul Evans 
    
5 years ago
What would the VBA code to prevent duplicates being entered into a SIGLE field be please?
Alex Hedley  @Reply  
           
5 years ago
Have you set it at a Table level?

Similar concept: Duplicate Values on Multiple Fields
Alex Hedley  @Reply  
           
5 years ago
Otherwise DLOOKUP on a BeforeUpdate
Paul Evans OP  @Reply  
    
5 years ago
All I would like is the VBA code for this proceedure that I could copy and paste into the field that I want to use it in. I am unable to set at Table level for some reason that I don't understand. Thanks.
Adam Schwanz  @Reply  
           
5 years ago
This would be much simpler to setup on table level with indexing. What's it saying that it wont allow that?
Adam Schwanz  @Reply  
           
5 years ago
If you want to try some kind of VBA code though, I think you could try something like this using your field names. Up to you if you keep the Me.Undo in there

    If SerialNumber = DLookup("SerialNumber", "TransmissionT", "SerialNumber=" & SerialNumber) Then
        Me.Undo
        MsgBox "Error, Duplicate"
    Else
        'not duplicate
    End If
Adam Schwanz  @Reply  
           
5 years ago
Or I think you could Dim a variable and use DCount as well - https://599cd.com/tips/access/dcount/

Then say something like this, just some ideas

If X <> 0 Then
'Duplicate
Else
'Not Duplicate
End If
Richard Rost  @Reply  
          
5 years ago
I agree with Adam. I can't think of a reason why you couldn't set this up at the table level. Indexed (No Duplicates).

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/8/2026 11:54:30 PM. PLT: 0s