Microsoft Access 2010 Bible

(Rick Simeone) #1

Part I: Access Building Blocks


152



  1. Run the query.


Figure 4.21 shows how the query should look.


FIGURE 4.21
Specifying text and date criteria in the same query

Access displays records of customers that live in Connecticut and who became customers after
January 1, 2012.

Cross-Reference
Advanced queries are covered in depth in Chapter 18.


Access uses comparison operators to compare Date fields to a value. These operators include less
than (<), greater than (>), equal to (=), or a combination of these operators.

Notice that Access automatically adds pound sign (#) delimiters around the date value. Access uses
these delimiters to distinguish between date and text data. The pound signs are just like the quote
marks Access added to the “Cars” criteria. Because OrigCustDate is a DateTime field, Access
understands what you want and inserts the proper delimiters for you.

Be aware that Access interprets dates according to the Regional and Language Options (Windows XP)
or the Region and Language settings (Windows 7) in the Windows Control Panel. For example, in
most of Europe and Asia, #5/6/2012# is interpreted as June 5, 2012, while in the United States this
date is May 6, 2012. It is very easy to construct a query that works perfectly but returns the wrong
data because of subtle differences in regional settings.

Cross-Reference
Operators and precedence are covered more in Chapter 5.

Free download pdf