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
Solved

How prevent duplicate records?

Posted on 2014-02-17
5
303 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
  • 2
  • 2
5 Comments
 
LVL 57
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 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

839 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