• Delete Dupes Part 2

    Author
    Topic
    #464422

    Hello again. (Access 2007)
    Having a staff table with StaffID, FirstName, Surnames duplicated, how can I delete the duplicates within this table – without creating a separate
    Append Query.. (I know I could copy the table, create a primary key and append data, but don’t wish to do it this way.)

    I believe this is a different query to my previous one. Thanks, Andy.

    Viewing 4 reply threads
    Author
    Replies
    • #1188628

      How do you decide which record to delete if there are two with the same StaffID, FirstName, Surname?

    • #1188629

      It’s not entirely clear to me why this is a different query, and using an append query seems an odd way to get rid of duplicates. Are you saying you have two or more records with the same StaffID, the same FirstName and the same Surnames?

    • #1188651

      Hiya.
      I’ve a single table with duplicate StaffIDs, FirstName and Surnames. I want to delete duplicates – keeping any one of the duplicates.
      Thanks, Andy.

      • #1188664

        I agree with Wendell that you have a serious issue with your table design.

        But you could do the following:
        – Add an AutoNumber field ID to the table.
        – Create and run the following query:

        DELETE *
        FROM tblStaff
        WHERE DCount(“*”,”tblStaff”,”StaffID=” & [StaffID] & ” AND FirstName='” & [FirstName] & “‘ AND Surname='” & [Surname] & “‘ AND ID>” & [ID])>0

    • #1188654

      The Find Duplicates option in the Query Builder Wizard should be able to identify those duplicates, and then you will need to manually pick one record to delete. However I should note that if you have duplicate Staff IDs, then you have a fairly serious design issue with your table. If you have records of another type linked to the Staff ID, such as addresses or phone numbers, then you pretty much have a shambles.

    • #1188709

      Hello.
      I was only giving an outline of my question – I agree that the table structures would be a mess.

      I can see that creating an AutoNumber field would help solve the problem. Thanks Andy.

    Viewing 4 reply threads
    Reply To: Delete Dupes Part 2

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: