Microsoft Access 2010 Bible

(Rick Simeone) #1

Part I: Access Building Blocks


150


You specify criteria in the Criteria row of the QBE grid. You designate criteria as an expression.
The expression can be as a simple example (like “trucks” or “not trucks”), or it can take the form of
complex expressions using built-in Access functions.

Proper use of query criteria is critical to an Access database’s success. In most cases, the users have
no idea what data is stored in a database’s tables and accept whatever they see on a form or report
as truthfully representing the database’s status. Poorly chosen criteria might hide important infor-
mation from the application’s users, leading to bad business decisions or serious business issues
later on.

Entering simple string criteria
Character-type criteria are applied to Text-type fields. Most often, you’ll enter an example of the
text you want to retrieve. Here is a small example that returns only product records where the
product type is “Cars”:


  1. Add tblProducts and choose the Description, Category, and Cost fields.

  2. Type CARS into the Criteria cell under the Category column.

  3. Run the query.


Only cars are displayed in the query’s results (see Figure 4.20). Notice that you did not
enter an equal sign or place quotes around the sample text, yet Access added double
quotes around the value. Access, unlike many other database systems, automatically
makes assumptions about what you want.


FIGURE 4.20
Specifying “Cars” as the query’s criteria
Free download pdf