Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2004
    Posts
    12

    Unanswered: Removing Records

    Hi All,

    I am having trouble deleteing some records from one of my tables using a delete query. I have a table of imported account numbers (T_Import) from Excel, that needs to be run against the main table in the database (T_Stock) and any duplicates removed.

    I have attempted to construct a delete query that will remove all records if the account number in T_Import is equal to that in T_Stock. No matter how I do it I can not make it work.

    Can anyone please help me? I am a bit of a novice at this!!

    Thanks...Pitz

    (Using Access 2000 on Windows 2000)

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    Does something like:

    Code:
    DELETE *
    FROM  T_Import
    WHERE EXISTS(SELECT NULL FROM T_Stock WHERE T_Stock.ID = T_Import.ID)
    work ok?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jul 2004
    Posts
    12
    Thanks for the reply!

    I have attempted your suggestion, but I get 'Enter Parameter Value' for T_Review.ID !?!?

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    Without the structure of the table, and the primary keys (field(s) that uniquely identify each row), I couldn't know which fields to search on. ID is just some generic field I have made up - replace that with the field that you would want to check for duplication on. If there is more than one field then something like:

    Code:
    DELETE *
    FROM  T_Import
    WHERE EXISTS(SELECT NULL FROM T_Stock WHERE T_Stock.ID = T_Import.ID AND T_Stock.ID2 = T_Import.ID2 AND T_Stock.ID3 = T_Import.ID3)
    and so on.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by Pitz
    Thanks for the reply!

    I have attempted your suggestion, but I get 'Enter Parameter Value' for T_Review.ID !?!?
    BTW - I presume you mean T_Import.ID or T_Stock.ID?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Jul 2004
    Posts
    12
    Sory for the late reply.... Your Query has worked a treat. Thanks very much for your help
    Cheers.....Pitz

    (Using Access 2000 on Windows 2000 Professional)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •