Results 1 to 3 of 3
  1. #1
    RuthSBT is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jan 2017
    Posts
    1

    Checking for duplication when adding new data

    I am very new to Access 2016 and learning as I go along. I have transferred a fairly large amount of data from excel to access, and want to know if I can replicate one of the functionalities of Excel. The way we had the spreadsheet set up was that, if we were adding trainee details that included an email address already in the spreadsheet, Excel would automatically highlight it in red for us to check out. Is there a way of doing this in access?



    I hope this makes sense!

    Thanks

    Ruth

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    You could use DLookUp function for this to look in your table for that email address. In the AfterUpdate Event of that email field on the form, use something llike.

    If Not Isnull(DLookup("RecID", "YourTable", "TraineeEmail = '" & Me.TraineeEmail & "'")) Then
    Msgbox "Email is a duplicate"
    me.TraineeEmail.Forecolor = vbRed
    Me.TraineeEmail.SetFocus
    End
    End If

    There is also a Find Duplicates Query Wizard that can help you find these in your table after the fact if you choose to do that.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    yes. A number of ways

    nearest to the excel functionality is in the form, use conditional formatting on the email control combined with a dcount function to produce a red background -

    something like
    Expression is...dcount("*","myTable","[Email]='" & [Email] & "'")>1
    and set the backcolor to red

    other alternatives include setting the index property of the field to indexed, no duplicates which will prevent users adding a duplicate

    or in code behind the email control after update event you can put something which outputs a message which can tell the user not only there is a duplicate, but also which record the duplicate can be found - even filter the form temporarily so a direct comparison can be made

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

Similar Threads

  1. Data Duplication Problem
    By bronson_mech in forum Programming
    Replies: 1
    Last Post: 06-17-2014, 06:20 AM
  2. Checking\validating data in a subform?
    By shabbaranks in forum Programming
    Replies: 1
    Last Post: 03-26-2012, 05:20 AM
  3. Duplication of data
    By Nixx1401 in forum Reports
    Replies: 1
    Last Post: 12-12-2011, 10:05 PM
  4. Checking if data already exist in a Table
    By Phillsoft in forum Forms
    Replies: 1
    Last Post: 08-04-2011, 08:03 AM
  5. Checking for data in table
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 07-27-2010, 01:32 PM

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