Solved

How prevent duplicate records?

Posted on 2014-02-17
5
299 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 Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now