Results 1 to 10 of 10
  1. #1
    zdjbel is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Apr 2012
    Posts
    42

    Highlighting duplicate records in a form

    Hello,

    I have a form called fBookings which pulls data from 2 tables:

    · field [Guest] in table tGuest, and
    · field [ArrDate] in table tBookings



    How can I highlight the field [Guest] in form fBookings if there are multiple instances of the same guest [Guest] arriving on the same date [ArrDate]?

    Thanks much!

    ZDJBEL

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Perhaps you could use DCount() function with criteria to determine if there are any duplicate records in the forms On Current event.
    IMHO it might be better to use the wizard to create a Find Duplicates query and then use some validation on the form or at table level to prevent duplicates in the first place.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Why do you have duplicates? I suggest you adjust your logic to identify and prevent duplicates.
    As Bob said, you could try using a DCount function. If the result is >0, then such a record exists---don't add another.

    Another option is to use prudent choice for composite unique index on the fields involved. Access will give a trappable error if you try to create a duplicate entry.

    Good luck.

  4. #4
    zdjbel is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2012
    Posts
    42
    Hello Orange,

    Thank you for suggesting looking at composite indexes, reviewing them made some queries work better. Unfortunately, I have to be able to see duplicate records because I import an Excel spreadsheet containing several hundred records on a twice daily basis which several people work on. Duplication happens occasionally, and I need to catch them when they happen to prevent issues down the "production" line. Being able to highlight them would save me a lot of time time and aggravation, so I'll look into DCount and see if I can figure out how to use it with text and date criteria.

    Thanks,

    Zdjbel

  5. #5
    zdjbel is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2012
    Posts
    42
    Hello Bob,

    The Find Duplicates query works of course, but I'm looking for a solution that will work in the form I have on the screen. Thanks for the suggestion where to put the DCount expression, I'll try it as soon as I figure out how to combine text and date criteria.

    Many thanks,

    Zdjbel

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    I would avoid importing duplicate data. In other words, use a temp table and validate your data before updating your production tables(s) from the temp table.

  7. #7
    zdjbel is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2012
    Posts
    42
    That's a good strategy and probably the best way to go about this, thanks for the suggestion.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe check out the Query Wizard and try the Unmatched option. After you run the wizard, you can create multiple joins on multiple columns, duplicating the criteria for each joined column that checks for Null.

  9. #9
    zdjbel is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2012
    Posts
    42
    Hello ItsMe,

    I tried the Unmatched Query Wizard and it worked fine. I also found a very informative and well written article on the subject here which helped me solve my problem of finding not only how to identify daily additions to the table but also deletions. Thank you for your suggestions and help.

    Zdjbel

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Great, glad you were able to accomplish the task and thank you for posting how you got there.

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

Similar Threads

  1. Highlighting required fields on a form
    By decco21 in forum Forms
    Replies: 6
    Last Post: 02-18-2015, 08:26 PM
  2. Duplicate Records Form and Subform
    By Michael Hilton in forum Access
    Replies: 0
    Last Post: 10-29-2013, 02:00 PM
  3. Replies: 2
    Last Post: 02-28-2013, 07:29 AM
  4. Duplicate records in Form view
    By Reh in forum Database Design
    Replies: 7
    Last Post: 08-10-2011, 07:21 AM
  5. Replies: 10
    Last Post: 04-19-2011, 03:38 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