Results 1 to 3 of 3
  1. #1
    Euler271 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2017
    Posts
    63

    Delete query not working

    I'm trying to delete some records in a table called T1 using the values in a second table called T2. My SQL statement is:

    DELETE T1.* FROM T1 LEFT JOIN T2 ON T1.Field1 = T2.Field1 AND T1.Field2 = T2.Field2 WHERE T2.Field1 IS NULL

    I'm getting error 3086 "Could not delete from specified tables."



    Can anyone tell me what's going on and how to make it run?

    Sorry but I found the reason. Apparently, I need to set the Unique Records property to "Yes" for the query. Now I'm wondering how to do this in VBA.

    I found that I need the DISTINCTROW reserved word:

    DELETE DISTINCTROW T1.* FROM T1 LEFT JOIN T2 ON T1.Field1 = T2.Field1 AND T1.Field2 = T2.Field2 WHERE T2.Field1 IS NULL

    Now it works. Hope this helps somebody else.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by Euler271 View Post
    Sorry but I found the reason. Apparently, I need to set the Unique Records property to "Yes" for the query. Now I'm wondering how to do this in VBA.
    Switching between design and SQL view, compare the SQL before and after changing that property, and you should see what needs to be added to the SQL. .
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Delete query working very slow
    By jaryszek in forum Queries
    Replies: 1
    Last Post: 07-27-2017, 02:52 AM
  2. On Delete Event Not Working
    By pdowg881 in forum Access
    Replies: 2
    Last Post: 05-21-2015, 11:18 AM
  3. Replies: 1
    Last Post: 01-16-2013, 10:58 AM
  4. Replies: 4
    Last Post: 08-14-2012, 11:56 AM
  5. Replies: 0
    Last Post: 04-08-2010, 12:22 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