If you have to delete all records from a table using Access VBA DAO, the following method might be helpful.

Source Code

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
27
28
29
30
' @Author - Alexander Bolte
' @ChangeDate - 2017-09-08
' @Description - Deletes all records from a provided table.
' @Param tableName - A table to delete all records from.
Private Function clearTable(ByVal tableName As String) As Boolean
    Dim qu As DAO.QueryDef
    Dim isCleared As Boolean
    
    On Error GoTo errHandle:
    
    ' Switch off warnings during deletion of records.
    ' Else user is asked, if he really wants to delete records.
    DoCmd.SetWarnings False
    
    Set qu = New QueryDef
    qu.sql = "Delete from [" & tableName & "]"
    DoCmd.RunSQL qu.sql
    
errHandle:
    If Err.Number <> 0 Then
      Err.Clear
    Else
        isCleared = True
    End If
    
    ' Switch system warnings on again.
    DoCmd.SetWarnings True
    Set qu = Nothing
    clearTable = isCleared
End Function