Results 1 to 5 of 5
  1. #1
    priceman31 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Location
    Tampa, FL
    Posts
    7

    Delete Duplcates Using Criteria

    I have a database that I am building and the data will be inserted a few times a day. The data set only changes when more is added. In essence most of the data will be duplicated on the next data pull.



    What I would like to be able to do is delete duplicates from a table if 2 fields are duplicated and the ID of the record is higher(ID's are incremental). I would want to delete the record(s) that have the higher ID number.
    I have seen some ways but they were very convoluted and I wasn't able to make them work for my needs.

    Any help would be greatly appreciate

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I would approach it a bit differently.

    I would import the new data into a "temporary" table, which is really just a blank copy of your final table.
    Then, do an Unmatched query between the two tables to find the new records, and then turn that into an Append Query to just add those records to the final table.
    After that, delete all records out of your temporary table, to prepare it for the next file load.

  3. #3
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    How are you importing the data into that table each time? Is there a append query? How many records are usually added each time? What fields do you check to see if it is a duplicate? Sounds like ID is the key field and unique?

    I would check for dups before importing into table and only write those that are not dups. Also if the dupes were already in table, you could maybe use query with Totals/GroupBy on ID to Min (other fields GroupBy) which I think would give you the first record only of any dupes.

  4. #4
    priceman31 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2017
    Location
    Tampa, FL
    Posts
    7
    I am importing the data from an excel sheet. Long story short source data is a mess so using excel to reformat and using Transferspreadsheet code to import into table. The # of records will vary. One of the fields would be a date field and the other an pre-assigned text string.

  5. #5
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    So, have you given any thought to using the approach Bulzie and I recommended?

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

Similar Threads

  1. delete records from datevalue criteria
    By enfapro7 in forum Queries
    Replies: 5
    Last Post: 10-04-2016, 04:34 AM
  2. Delete query with criteria from another table
    By FuelingAround in forum Queries
    Replies: 3
    Last Post: 10-20-2015, 06:46 PM
  3. Replies: 6
    Last Post: 06-24-2014, 10:09 PM
  4. Delete Query - Use Another Table As Criteria
    By Madmartigan in forum Access
    Replies: 4
    Last Post: 07-12-2013, 01:15 PM
  5. Delete Duplicate Records Based on Criteria
    By chadd in forum Queries
    Replies: 2
    Last Post: 02-07-2012, 04:24 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