Database Reference
In-Depth Information
EXAMPLE 17
56
Delete all order lines in which the order number is 21610.
You enter the criteria that will determine the records to be deleted just as you would enter any other
criteria. In this example, include the OrderNum field in the design grid and enter the order number 21610 in
the Criteria row, as shown in Figure 2-36. To change the query type to a delete query, click the Delete but-
ton in the Query Type group on the Query Tools Design tab. Notice that a new row, called the Delete row, is
added to the design grid, indicating that this is a delete query. When you click the Run button, Access indi-
cates how many rows will be deleted and gives you a chance to cancel the deletions, if necessary. If you click
the Yes button, the query will delete all rows in the OrderLine table in which the order number is 21610.
Because the result of a delete query permanently deletes the records it selects, you should take extra care to
make sure that the query design selects the correct records.
Q&A
Question: What happens if you run a delete query that does not include a criterion?
Answer: Because there is no criterion to select records, the query selects all records in the table and then
deletes all of them from the table.
Delete
button
Delete row
added to
design grid
Field
containing
criterion
Criterion
FIGURE 2-36
Query design to delete records
USING A MAKE-TABLE QUERY
You can use a query to create a new table in either the current database or another database. A make-table
query creates a new table using the results of a query. The records added to the new table are separate from
the original table in which they appear; in other words, you don
'
t move the records to a new table; you cre-
ate a new table using the records selected by the query.
Search WWH ::




Custom Search