Share this Page URL

Chapter 9. Extending Your Use of Queries > Running Action Queries - Pg. 314

Extending Your Use of Queries 314 Safeguard Your Data An action query changes data, and in most cases, you can't undo the changes the query makes. You can lose important data if you don't take precautions before you run an action query. The minimum step you should take before running an action query is to switch to Datasheet view. The data-sheet shows which records will be modified by the query, so you can check whether the query will act on the correct set of records. A more secure approach is to create a copy of the table or tables that the action query will affect before you run the query. Then, after running the query, review the table the query acted on and check whether the modifications are correct. If something went wrong, you can delete the modified table and rename the copy with its original name. Of course, you'll also want to modify the query so that it works as you intend. Updating Field Values with a Query Some of your most important data can remain unchanged for a fairly long period of time. Product prices, for example, usually aren't updated daily, whereas one or more orders come in every day. With an update query, you can modify the values in a field for a group of records all at once, using criteria to define the changes you want to make. You enter the criteria in the query design grid in a row named Update To, which is displayed when you indicate to Access that you're creating an update query. By using an expression such as the following, for example, you could increase unit prices for all products by 10 percent: Naming action queries If you're using a naming convention that includes prefixes to identify database objects, you can use qupd for an update query, qdel for a delete query, qapp for an append query, and qmak for a make-table query.