DELETE Statement Example (DAO)

Microsoft Jet SQL Reference

DELETE Statement Example

This example deletes all records for employees whose title is Trainee. When the FROM clause includes only one table, you do not have to list the table name in the DELETE statement.

Sub DeleteX()

    Dim dbs As Database, rst As Recordset

    ' Modify this line to include the path to Northwind

    ' on your computer.

    Set dbs = OpenDatabase("Northwind.mdb")

    ' Delete employee records where title is Trainee.    

    dbs.Execute "DELETE * FROM " _

        & "Employees WHERE Title = 'Trainee';"

    

    dbs.Close

End Sub