Delete Queries
Delete queries are the simplestâand most dangerousâof the action queries. A delete query works much like a normal select query. You specify a set of filter conditions, and then Access finds the matching records in the table. But the delete query doesnât just display the recordsâinstead, it erases them from the database.
Note
Think twice before you delete anything. You just might need old information for reporting and analysis. Editing a Table explains why.
Delete queries are great for clearing out a huge number of records at once after youâve finished transferring them to another table. In the append-query example described earlier (Creating an Append (or Make-Table) Query), you probably want a way to remove the original records once youâve copied them to the new table. A delete query fits the bill perfectly.
To create a delete query, follow these steps:
Create a new query by choosing CreateâQueriesâQuery Design.
Using the Show Table dialog box that appears, add the table that has the records you want to delete. Then click Close to close it.
Change your query to a delete query by choosing Query Tools | DesignâQuery TypeâDelete.
The Sort and Show boxes disappear from the column list, and the Delete box appears.
Add the fields you want to use for filtering, and then set your filter conditions.
Your filter conditions determine what records are deleted, so make sure you define them carefully. If you donât include any filter conditionsâgulpâAccess will ...
Get Access 2010: The Missing Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.