Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How prevent duplicate records?

Posted on 2014-02-17
5
Medium Priority
?
315 Views
Last Modified: 2015-07-30
I have a form which contains a field that is a "combination" field made up of other fields on the form.  The form is bound to a table and the field is actually in a field in the table.

For example the form has "FirstName", "LastName","City"  Or like "John Smith Greendale".

Since it is not the primary key field I want to find a way to prevent the user from entering the record since it already exists and alert the user that that record already exists and not let them enter it again.

How can I do this?
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 58
ID: 39865419
There are two ways:

1. In table design, but a unique index on the field(s).  An error will result when the user goes to save the record, which you can trap in the forms On Error event if you wish.

2. As soon as the user enters all the fields, or when they go to save the record, do a find on the existing records for all the fields and message or not as appropriate.

Jim.
0
 

Author Comment

by:SteveL13
ID: 39865441
How do I put a unique index on the fields?
0
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 39865468
<<How do I put a unique index on the fields? >>

1. open the table in design view.
2. click the indexes button on the toolbar.
3. On the first blank line, enter an index name (doesn't matter really what it is, but it must be unique).
4. List the first field off to the right.
5. If there are additional fields that make up the key for the index, list them in the lines following.  Don't not repeat the index name.
6. Click back on the row with the index name.
7. In the properties window below, indicate that duplicates are not allowed.

Jim.
0
 

Author Closing Comment

by:SteveL13
ID: 39865605
Worked. Thanks.
0
 

Expert Comment

by:SVong
ID: 40906316
Anyone please!
I am new in this Experts Exchange.
Please help How prevent duplicate records in SQL table using VB.Net 2012? (How to write the VB Code for that I meant).
Best regards,
SVong
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question