Results 1 to 13 of 13
  1. #1
    bklewis is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    12

    Duplicate Entry Prevention


    I am a beginner to Access but have managed to create a database and a form that I use to input information into the main table. The form allows me to enter information into 9 fields for each record. The first field is set not to allow duplicates, however, I do not know that I have entered a duplicate until I complete the entire record entry and move to a new record. I would like for Access to check the 1st field for duplication as soon as the field is updated, give me a message box stating that there is a duplicate record, and give me an option to display the duplicate record (in the form) in edit mode. If this is something that someone would be willing to help me with I will be happy to provide table/form/field names so that you can use this information in the code and I can better understand the required text.

    Thank you!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You can use a DLookup() in the BeforeUpdate event of the control.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847

  4. #4
    bklewis is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    12
    Will the DLookup() function provide the message and a the duplicate record in a form so that I can edit it or will it simply tell me if there is another record with a duplicate field entry?

  5. #5
    bklewis is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    12
    Quote Originally Posted by orange View Post
    How do you define duplicate?
    Another record with an exact match in the first field.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by bklewis View Post
    Will the DLookup() function provide the message and a the duplicate record in a form so that I can edit it or will it simply tell me if there is another record with a duplicate field entry?
    No. You will need to implement that in the code as well.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Can you tell us more about your table? What are the fields?
    You can use Dlookup or Dcount to find out if another records with a field value already exists.
    You could probably do some programming to edit, start over....

  8. #8
    bklewis is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    12
    Quote Originally Posted by orange View Post
    Can you tell us more about your table? What are the fields?
    You can use Dlookup or Dcount to find out if another records with a field value already exists.
    You could probably do some programming to edit, start over....
    There are 9 fields in the table. 4 Text fields, 1 hyperlink, and 4 Yes/No fields. The first field is named "Code". It is a text field consisting of 5 alpha characters and is set to Indexed with no duplicates. This is the field that I would like Access to check the database for duplicate entries and report it to me so that I do not continue entering data in the remaining 8 fields. It would also be nice if Access would automatically display the duplicate record in form view so that I could edit one of the fields with additional information if needed.

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847

  10. #10
    bklewis is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    12
    The code field represents a unique code (made up of 5 alpha characters) given to each person in the database. You could think of it as a serial number for each person. No two people would have the same number. There is no reasoning behind the value in the code field. It is not in any particular alphabetical order or sequential order at all.

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Perhaps you should tell us more about WHAT you are doing/planning. It's possible that your tables and/or forms could be set up differently to help you with duplicate prevention.

  12. #12
    bklewis is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    12
    I am sorry that this is so difficult and appreciate your help. I have attached my database with an example record so that you can see what I am trying to do. Instead of entering information on a record and tabbing to the next new record and finding out that there is a duplicate alliance code entry already in the database, I would like Access to search for a duplicate after I update the alliance code field in my form, tell me that there is a record with a duplicate code, and pull up the existing record in a form in edit mode so that I may modify the record with the new information.
    Attached Files Attached Files

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    I suggest you add a field called

    PersonId Autonumber and make it Primary Key and let Access take care of it.

    On your form add a combobox
    make the recordsource of the combo
    SELECT [tbl_Alliance_Codes].[PersonID], [tbl_Alliance_Codes].[Alliance Code] FROM [tbl_Alliance_Codes] ORDER BY [Alliance Code];

    hide the personId and show alliancecodes alphabetically

    When you add a new record you can check visually to make sure it isn't in the combo's list

    Just my $.02

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Duplicate data entry on form level by user
    By Kananelo in forum Forms
    Replies: 1
    Last Post: 02-10-2012, 01:09 AM
  2. Duplicate Entry Error
    By Dee300 in forum Forms
    Replies: 3
    Last Post: 08-16-2011, 07:29 PM
  3. Prevent Duplicate Entry
    By kilosierra71 in forum Forms
    Replies: 4
    Last Post: 07-28-2011, 03:08 PM
  4. Scanning table for duplicate entry from VBA
    By Buakaw in forum Programming
    Replies: 6
    Last Post: 03-08-2011, 07:29 PM
  5. MsgBox for duplicate entry
    By usmcgrunt in forum Programming
    Replies: 3
    Last Post: 11-09-2010, 08:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums