O'Reilly logo

Access 2010: The Missing Manual by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. Create a new query by choosing Create→Queries→Query Design.

  2. 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.

  3. 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.

  4. 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 delete all the records when ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required