![]() Getting to Know Microsoft Access 2003
1
A
query
is essentially a question. For example, you might ask, “Which records in the
Customer table have the value 98052 in the Postal Code field." When you
run a query
(the equivalent of asking a question), Access looks at all the records in the table or
tables you have specified, finds those that match the criteria you have defined, and
displays them in a datasheet.
For Access to be able to answer your questions, you have to structure queries in
a specific way. Each type of question has a corresponding type of query. The primary
query types are select, crosstab, and parameter. Less common types are action,
AutoLookup, and SQL (Structured Query Language). Access includes wizards that guide
you through the creation of the common queries; less common ones have to be created
by hand in a
design grid
in Design view. Here’s what a typical query looks like:
Relationship between tables
T
ab
l
e
fi
e
l
d
li
st
Table area
Design grid
At the top of this query window are four small windows listing the fields in the four
tables that will be included in this query. The lines connecting the tables indicate
that they are related by virtue of common fields. The first row of the grid contains
the names of the fields to be included in the query, and the second row shows which
table each field belongs to. The third row (labeled Total) performs calculations on
the field values, and the fourth row indicates whether the query results will be sorted
on this field. A check mark in the check box in the fifth row (labeled Show) means
that the field will be displayed in the results datasheet. (If the check box isn’t selected,
the field can be used in deter mining the query results, but it won’t be displayed.)
The sixth row (labeled Criteria) contains criteria that determine which records will
be displayed, and the seventh row (labeled or) sets up alternate criteria.
Don’t worry if this all sounds a bit complicated at the moment. When you approach
queries logically, they soon begin to make perfect sense. And don’t worry if they
sound like a lot of work. The Query Wizard is available to help you structure the
query, and if you create a query that you are likely to run more than once, you can
save it. It then becomes part of the database and is displayed in the database window
when you click Queries on the Objects bar.
11
|
|