Results 1 to 14 of 14
  1. #1
    Blackkimba851 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    16

    Question Check for Duplicate Records

    Using Access 2007
    I have 4 fields. Autonumber, Room, Task, Status. Using a button to enter the new record from a form created from a table how do i check for duplicate records with all 3 fields (not including Autonumber) before access enters the new record? I would like to have a message box open to warn of duplicates and then return to form at the same place, not removing the options from the fields (using combobox's) so the client can see the error and fix it. Is this possible using a macro or dlookup? I tried a macro with a Query, IF statement like this- (on button click)

    (IF [Room]=Forms![Room Tasks Query]![Room] And [Task]=Forms![Room Tasks Query]![Task] And [Status]=Forms![Room Tasks Query]![Status]

    but it errored for every record duplicated or not.

    Names of Forms



    Table-Room Tasks
    Form-Room Tasks
    Query-Room Tasks Query

    I would snapshot the macro but haven't figured out how to do that yet.
    Any help would be appreciated.

    Blackkimba

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Use the FORM name in the macro.

    IF [Room]=Forms![Room Tasks]![Room] And [Task]=Forms![Room Tasks]![Task] And [Status]=Forms![Room Tasks]![Status]
    Last edited by davegri; 03-30-2019 at 08:11 AM. Reason: sp

  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

  4. #4
    Blackkimba851 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    16
    would this also work using a split form

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    would this also work using a split form
    Pretty easy to try it.

  6. #6
    Blackkimba851 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    16
    Like this? IF [Room Tasks]![Room]=[Forms]![Room Tasks Query]![Room] And [Room Tasks]![Task]=[Forms]![Room Tasks Query]![Task] And [Room Tasks]![Status]=[Forms]![Room Tasks Query]![Status]

  7. #7
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Like this?
    No. Look at post #2 again.

  8. #8
    Blackkimba851 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    16
    Ok I tried it but it didn't work. let's forget what I'm trying. How would you do it?

  9. #9
    Blackkimba851 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    16
    It didn't seem to work either

  10. #10
    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
    @blackimba851

    The issue is storage of duplicate data in the table, so to remove it and prevent the acceptance of duplicates in the fields you identified:

    -make a new table (tblNew) with same fields as the table involved
    -create a unique composite index on the fields you want to be unique in all records (a per link in post #3)
    - copy your existing table to this new table and you duplicates will be identified and will not be saved
    - the new table will now have only unique values for the fields involved for all records
    - rename your old table with some suffix eg -OLD
    - rename the new table with the name you have been using with form etc.

    Good luck.

  11. #11
    Blackkimba851 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    16
    I'll giver a try

  12. #12
    Blackkimba851 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    16
    that didn't seem to work either. The problem it seems to have is that when I pick the same room twice it calls the error.

  13. #13
    Blackkimba851 is offline Novice
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    16
    Using the index didn't work. it calls an error if any of the fields are a duplicate. not all 3

  14. #14
    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
    Did you follow the sample at the link in post #3?
    You could post a copy of the database (zip format).

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

Similar Threads

  1. Replies: 3
    Last Post: 01-09-2014, 08:34 PM
  2. Check For Duplicate Check Before Posting.
    By burrina in forum Queries
    Replies: 1
    Last Post: 01-22-2013, 01:39 PM
  3. How to check if there is duplicate entry
    By undee69 in forum Forms
    Replies: 8
    Last Post: 12-17-2012, 10:34 AM
  4. check duplicate records within same table
    By cthorn112 in forum Queries
    Replies: 0
    Last Post: 06-19-2012, 12:23 PM
  5. check for duplicate First and Last names?
    By newtoAccess in forum Access
    Replies: 3
    Last Post: 03-19-2011, 04:05 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