Results 1 to 2 of 2
  1. #1
    kshope25 is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2012
    Posts
    1

    Delete Query based on results in a seperate table

    I need to delete records from tblshipmentdata_working based on info in LITSO. My code is below:.



    The problem is that the query is pulling all the records in tblshipmentdata_working that are in LITOSD for Plant and Code. I want it to only pull records where Plant and Code are equal in the same rows as in LITOSD



    DELETE*
    FROM tblshipmentdata_working
    WHERE (((tblshipmentdata_working.Plant) In (SELECT LITOSD.Plant FROM LITOSD)) AND ((tblshipmentdata_working.Code) In (SELECT LITOSD.Code FROM LITOSD)) AND ((tblshipmentdata_working.Active)=-1));

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Have you tried using the query wizard just to select the records you intend to delete?
    You could then convert to a DELETE query.

    Untested but I think your query would look like this

    select tblshipmentdata_working.*
    FROM tblshipmentdata_working
    Inner Join LITOSD
    ON tblshipmentdata_working.Plant = LITOSD.Plant AND
    tblshipmentdata_working.Code = LITOSD.Code
    WHERE ((tblshipmentdata_working.Active)=-1);

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

Similar Threads

  1. Replies: 2
    Last Post: 01-24-2012, 02:16 PM
  2. Replies: 3
    Last Post: 07-16-2010, 12:32 PM
  3. Replies: 3
    Last Post: 05-21-2010, 03:57 PM
  4. Replies: 0
    Last Post: 04-08-2010, 12:22 PM
  5. Open form based on query results
    By RobbertH in forum Queries
    Replies: 1
    Last Post: 02-10-2010, 08:13 AM

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