Microsoft Access 2010 Bible

(Rick Simeone) #1

Part I: Access Building Blocks


208


Tip
When using the Is Null and Is Not Null operators, you can enter Null or Not Null and Access automat-
ically adds the Is to the Criteria field.


Entering Criteria in Multiple Fields


Earlier in this chapter, you worked with single and multiple criteria specified in single fields. In
this section, you work with criteria across several fields. When you want to limit the records based
on several field conditions, you do so by setting criteria in each of the fields that will be used for
the scope. Suppose you want to search for all sales of models to resellers in Kansas (KS). Or sup-
pose you want to search for motorcycle model buyers in Massachusetts or Connecticut. Or sup-
pose you want to search for all motorcycle buyers in Massachusetts or trucks in Connecticut. Each
of these queries requires placing criteria in multiple fields and on multiple lines.

Using And and Or across fields in a query
To use the And operator and the Or operator across fields, place your example or pattern data in
the Criteria cells (for the And operator) and the Or cells of one field relative to the placement in
another field. When you want to use And between two fields, you place the example or pattern
data across the same row in the QBE pane. When you want to use Or between two fields, you
place the criteria on different rows in the QBE pane. Figure 5.16 shows the QBE pane and a rather
extreme example of this placement.

FIGURE 5.16

The QBE pane with And/Or criteria between fields using the Criteria and Or rows


Figure 5.16 shows that if the only criteria fields present were Criteria1, Criteria2, and
Criteria3 (with Criteria4 and Criteria5 removed), all three would be And-ed between
the fields. If only the criteria fields Criteria4 and Criteria5 were present (with Criteria1,
Criteria2, and Criteria3 removed), the two would be Or-ed between fields. As it is, the
Free download pdf