Deleting a Table with SQL command : Table Delete « Access « VBA / Excel / Access / Word






Deleting a Table with SQL command

 
Sub DeleteTable()
    Dim conn As ADODB.Connection
 
    On Error GoTo ErrorHandler
    Set conn = CurrentProject.Connection

 
    conn.Execute "DROP TABLE myTable"
    Application.RefreshDatabaseWindow
ExitHere:
    conn.Close
    Set conn = Nothing
    Exit Sub
ErrorHandler:
    If Err.Number = -2147217900 Then
        DoCmd.Close acTable, "myTable", acSavePrompt
        Resume 0
    Else
        Debug.Print Err.Number & ":" & Err.Description
        Resume ExitHere
    End If
End Sub

 








Related examples in the same category

1.Deleting a Table from a Database