Results 1 to 3 of 3
  1. #1
    lquigley is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2015
    Posts
    1

    Need help Deleting Dup records but leaving the first

    Thanks guys, I already got an answer from another forum.


    I am new to access. Using Access 2010. I am working trying to delete duplicate records from a table.
    I have set a unique key to the table [tbl_Cmbn_RateSheetTerms_Audit_Collapsed] in order to identify duplicate data within the table for the field [RATESHEETCODE]
    I then created a query [qry_000e_list_of_firsts_RS_collapsed] to identify the first record of the duplicates here is the SQL: SELECT First(tbl_Cmbn_RateSheetTerms_Audit_Collapsed.Uniq ueKey) AS FirstOfUniqueKey, tbl_Cmbn_RateSheetTerms_Audit_Collapsed.RATESHEETC ODE FROM tbl_Cmbn_RateSheetTerms_Audit_Collapsed GROUP BY tbl_Cmbn_RateSheetTerms_Audit_Collapsed.RATESHEETC ODE;



    I then created a query [qry_000f_list_to_delete_RS_collapsed] to identify the records that need to be deleted. I used my original table tbl_Cmbn_RateSheetTerms_Audit_Collapsed and the query qry_000e_list_of_firsts_RS_collapsed linked them by unique key here is the SQL: SELECT tbl_Cmbn_RateSheetTerms_Audit_Collapsed.UniqueKey, tbl_Cmbn_RateSheetTerms_Audit_Collapsed.ReportMont hYr, tbl_Cmbn_RateSheetTerms_Audit_Collapsed.RATESHEETC ODE
    FROM tbl_Cmbn_RateSheetTerms_Audit_Collapsed LEFT JOIN qry_000e_list_of_firsts_RS_collapsed ON tbl_Cmbn_RateSheetTerms_Audit_Collapsed.[UniqueKey] = qry_000e_list_of_firsts_RS_collapsed.[FirstOfUniqueKey]
    WHERE (((qry_000e_list_of_firsts_RS_collapsed.FirstOfUni queKey) Is Null));

    I am now trying to create a third and final query to delete the duplicates from the original table. I was attempting to do this using dlookup but I can't figure it out. HELP PLEASE!!!!
    Last edited by lquigley; 09-16-2015 at 10:37 AM. Reason: Figured out

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    The only way to use a query to delete in another query is the IN subquery.
    First, use the Query Wizard and make a FIND DUPLICATEs query, any table.
    Now edit the query,
    Note the field with the dupes has a sub-query in the critieria. This is what you do but with a delete query.
    this subquery will be the one you made above. But it only needs the rec.key as the only field.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Query leaving records out
    By Waterdog in forum Queries
    Replies: 3
    Last Post: 07-24-2015, 01:26 PM
  2. Replies: 4
    Last Post: 07-15-2013, 12:30 PM
  3. Replies: 3
    Last Post: 02-02-2011, 01:00 PM
  4. deleting records
    By radicalrik in forum Queries
    Replies: 2
    Last Post: 07-14-2010, 03:10 PM
  5. Problem Deleting Records with ADO
    By bdicasa in forum Programming
    Replies: 0
    Last Post: 08-21-2008, 09:27 AM

Tags for this Thread

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