Results 1 to 3 of 3

Thread: deleting records in access

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    England
    Posts
    135

    deleting records in access

    hi there,

    i have 2 tables which i am now trying to merge together and it wont let me delete the duplicate records. I have a unique number on each record in one table and the same unique number exists in the second table (not autonumber though). I check to see which ones are duplicated and then if certain conditions are met, i need to delete from the second table, but access says that i cant delete as it is read only - why? This is using a delete record query.

    None of the files are read only and i can delete the records in the normal table view, but there are about 10,000.

    If you have any ideas, please let me know,
    Cheers,
    Sparky

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Hi

    Its because of the join.

    I've had problems deleting, and one way around was the link fields both have to be the primary key.

    Otherwise you need to (put all the duplicated IDs into another table and) loop through and delete each occurance of the duplication in teh second table. Or flag them in a field then delete using that field.

    Regards

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313
    Code:
    DELETE FROM Table2
    WHERE UniqueID IN 
       (SELECT UniqueID
        FROM Table1
        WHERE YourSpecialConditionsAreMet)
    This obviously won't work as it is - you'll need to sort out your WHERE clause, but it should give you a start. It probably won't be very quick for 10 000 records..!

    Also UNION queries remove duplicates, but you won't easily be able to meet your other conditions...

Posting Permissions

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



Click Here to Expand Forum to Full Width