Question : Why do I get "Invalid Qualifier" with the following code

Hello experts, in an effort to gain a greater understanding of coding in access, I'm trying to remove all my docmd. statements.  While they were handy initially, I feel they have reduced my knowledge curve.  That said, please tell me what I'm doing wrong in the code below and why do I get the message "Invalid Qualifier".  The DoCmd query was simply a delete everything from a table type.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
Sub SubEmptyPreviousWeeksData()

    Dim db As DAO.Database
    Dim QryDefinition As DAO.QueryDef
    Dim strSql As String
    
    On Error GoTo errorhandler
    
    strSql = "DELETE tmptblWeeklyInvoice.* FROM tmptblWeeklyInvoice;"
    
    Set db = OpenDatabase(CurrentProject.Path & "\MyComicShopTables.accdb")
    strSql.Execute
    
    db.Close
    Set db = Nothing
    
    QryDefinition.Close
    Set qrydefintion = Nothing
    
    Exit Sub
    
errorhandler:
    
    MsgBox Err.Number & ":" & Err.Description
    
End Sub

Answer : Why do I get "Invalid Qualifier" with the following code

I believe this:

    strSql = "DELETE tmptblWeeklyInvoice.* FROM tmptblWeeklyInvoice;"
   
    Set db = OpenDatabase(CurrentProject.Path & "\MyComicShopTables.accdb")
    strSql.Execute

Should be:

    strSql = "DELETE tmptblWeeklyInvoice.* FROM tmptblWeeklyInvoice;"
   
    Set db = OpenDatabase(CurrentProject.Path & "\MyComicShopTables.accdb")
    db.Execute strSql

mx
Random Solutions  
 
programming4us programming4us