Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    22

    Unanswered: DELETE SQL Error

    I have the following Code:

    Dim DelOld As DAO.QueryDef

    Set DelOld = CurrentDb.CreateQueryDef("", "DELETE * FROM CompetitiveFoodsTable CFT " & _
    "LEFT JOIN CompetitiveFoodsWorkingTable CFWT ON CFT.[Fox Item Num] = CFWT.[Fox Item Num] " & _
    "WHERE ((CompetitiveFoodsWorkingTable.[Fox Item Num]) Is Null)")
    DelOld.Execute

    And everytime I run it I am getting this error:
    “specify the table containing records you want to delete”

    I thought I would be able to get around this error using SQL, but I must have been mistaken or my SQL is written wrong any ideas?

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I would try:
    Code:
    DELETE FROM CompetitiveFoodsTable
    WHERE [Fox Item Num] IN (SELECT CompetitiveFoodsTable.[Fox Item Num] 
                               FROM CompetitiveFoodsTable LEFT JOIN 
                                    CompetitiveFoodsWorkingTable
                                 ON CompetitiveFoodsTable.[Fox Item Num] = CompetitiveFoodsWorkingTable.[Fox Item Num] 
                              WHERE CompetitiveFoodsWorkingTable.[Fox Item Num] Is Null
                            );
    Have a nice day!

Posting Permissions

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