Exploring Queries 773
- Click away from the gallery to close it.
- Right-click the tab of the Customers form, and then click Close All.
All the open database objects close.
CLEAN UP Retain the GardenCompany01 database for use in later exercises.
Exploring Queries
You can locate specific information stored in a table, or in multiple tables, by creating
a query that specifies the criteria you want to match. Queries can be quite simple. For
example, you might want a list of all products in a specific category that cost less than
$10. Queries can also be quite complex. For example, you might want to locate all out-
of-state customers who have purchased gloves within the last three months. For the first
example, you might be able to sort and filter the data in the Products table fairly quickly
to come up with a list. For the second example, sorting and filtering would be very tedious.
It would be far simpler to create a query that extracts all records in the Customers table
with billing addresses that are not in your state and whose customer IDs map to records
that appear in the Orders table within the last three months and that include item IDs
mapping to records classified as gloves in the Products table.
You can create queries by using a Query wizard, and you can also create them from scratch.
The most common type is the select query, which extracts matching records from one or
more tables. Less common are queries that perform specific types of actions.
Processing a query, commonly referred to as running a query or querying the database,
displays a datasheet containing the records that match your search criteria. You can
use the query results as the basis for further analysis, create other Access objects (such
as reports) from the results, or export the results in another format, such as an Excel
spreadsheet.
If you create a query that you are likely to want to run more than once, you can save it. It
then becomes part of the database and appears in the list when you display the Queries
group in the Navigation pane. To run the query at any time, you simply double-click it
in the Navigation pane. Each time you run the query, Access evaluates the records in the
specified table or tables and displays the current subset of records that match the criteria
defined in the query.