Database Reference
In-Depth Information
USING AN UPDATE QUERY
In addition to retrieving data, you can use a query to update data. A query that changes data is called an
update query. An update query makes a specified change to all records satisfying the criteria in the query.
To change a query to an update query, click the Update button in the Query Type group on the Query Tools
Design tab. When you create an update query, a new row, called the Update To row, is added to the design
grid. You use this row to indicate how to update the data selected by the query.
55
EXAMPLE 16
The zip code for customers located in the city of Fillmore is incorrect; it should be 33363. Change the zip
code for these customers to the correct value.
To change the zip code for only those customers located in Fillmore, include the City column in the
design grid and enter a criterion of Fillmore in the Criteria row. To indicate the new value for the zip code,
include the Zip column in the design grid and enter the new zip code value in the Update To row for the Zip
column, as shown in Figure 2-35. When you click the Run button in the Results group on the Query Tools
Design tab, Access indicates how many rows the query will change and gives you a chance to cancel the
update, if necessary. When you click the Yes button, the query is executed and updates the data specified in
the query design. Because the result of an update query is to change data in the records selected by the
query, running the query does not produce a query datasheet.
Update
button
Update To row
added to
design grid
Field to be
updated
Field
containing
criterion
New value
FIGURE 2-35
Query design to update data
USING A DELETE QUERY
You can also use queries to delete one or more records at a time based on criteria that you specify. A delete
query permanently deletes all the records satisfying the criteria entered in the query. For example, you can
delete all the order lines associated with a certain order in the OrderLine table by using a single delete query.
Search WWH ::




Custom Search