Results 1 to 3 of 3
  1. #1
    AlexSalvadori is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    14

    Delete query

    I have a table full of employee details, and an updated version of this table, Employees2, which was uploaded from an excel file. In E2 there are changes to the records, but some records have been deleted altogether, it is the most relevant version of the two tables in all ways except one... E1 currently holds some documentation, attachment fields for .PDF and .DOC etc (which was lost when exported/imported in E2).

    I know how to update E1 with the new data from E2, but I don't know how to delete the records in E1 that were deleted in E2 without going through them all manually. I'm thinking a delete Query matching the ID from E1 and E2, with a condition that says delete E1 where it does NOT equal E2 (ie, if its not in E2, delete it from E1.) But I don't know how to do this...

    here's what I've tried so far, but when I try to run it it tells me to specify the table containing records i want to delete...

    DELETE [Employees1].EmpDetID
    FROM [Employees1] INNER JOIN [Employees2] ON [Employees1].EmpDetID = [Employees2].EmpDetID
    WHERE ((([Employees1].EmpDetID)<>[Employees2]![EmpDetID]));
    Please help

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If I understand it correctly, you just want to delete people in Employees1 who are not in Employees2?
    Here is one way:
    Code:
    DELETE [Employees1].*
    FROM [Employees1] 
    WHERE [Employees1].EmpDetID Not In
    (SELECT [Employees2].EmpDetID
    FROM [Employees2]);

  3. #3
    AlexSalvadori is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Posts
    14
    that is exactly right thanks very much

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

Similar Threads

  1. Delete query using vba
    By gg80 in forum Programming
    Replies: 3
    Last Post: 08-27-2012, 11:15 AM
  2. Replies: 2
    Last Post: 01-24-2012, 02:16 PM
  3. Trying to Delete record using delete query
    By MooseOTL in forum Access
    Replies: 13
    Last Post: 10-04-2011, 02:30 AM
  4. Replies: 11
    Last Post: 03-30-2011, 01:08 PM
  5. HELP with Delete Query
    By brown in forum Queries
    Replies: 1
    Last Post: 04-22-2009, 10:11 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