Criteria can be set for fields that contain numeric data. When you design your table, you designate fields that will contain numbers, currency, or dates with a specific data type so that mathematical calculations can be performed.
In this activity, you will specify criteria in the query so that only the records of donors who pledged $25 display.
Be sure the Queries object button is selected, and then double-click Create query in Design view. From the Show Table dialog box, add Pledges, and then Close the Show Table dialog box.
Adjust the Query window to increase the size of the table area, and then expand the Pledges field list so all of the fields display.
From the Pledges field list, use any technique you have practiced to add the following fields to the design grid: Club Affiliation, Donor Last Name, Donor Phone, and Pledge Amount.
Click in the Sort row under Club Affiliation, click the list arrow, and then click Ascending. In the Criteria row, under Pledge Amount, type 25 and then compare your screen with Figure 2.26.
When entering currency values as criteria in the design grid, do not type the dollar sign, and include a decimal point only if you are looking for a specific amount that includes centsfor example 25.50.
Click the Run button to view the results.
On the Query Datasheet toolbar, click the View button . Leave the query open in Design view for the next activity.
Comparison operators are symbols that evaluate each field value to determine if it is the same (=), greater than (>), less than (<), or in between a range of values as specified by the criteria.
If no comparison operator is specified, equal (=) is assumed. For example, in Activity 2.13, you created a query to display only records where the Pledge Amount was 25. The comparison operator of = was assumed, and Access displayed only records that had entries equal to the number specified25.
In this activity, you will specify criteria in the query to display records from the Pledges table that have a pledge that is greater than or less than $25.
Be sure your query from the last activity is displayed in Design view. In the Criteria row, under Pledge Amount, delete the existing criteria, type >25 and then press . Compare your screen with Figure 2.27.
Unlike a text field, Access does not add quote marks around criteria entered in number or currency data type fields.
Click the Run button .
On the Query Datasheet toolbar, click the View button . In the Criteria row, under Pledge Amount, delete the existing criteria and type <25 and then click the Run button . Compare your screen with Figure 2.28.
Switch to Design view . In the Criteria row, under Pledge Amount, delete the existing criteria and type >=25 and compare your screen with Figure 2.29.
NotePressing Enter After Criteria Is Added
If you press or click in another column or row in the query design grid after you have added your criteria, you can see how Access alters the criteria so it can interpret what you have typed. Sometimes, there is no change, such as when a number is added to a number or currency field. Other times, Access may capitalize a letter or add quote marks or other symbols to clarify the criteria. Whether or not you press after criteria is added does not affect the query results. It is used in this text to help you see how the program behaves.
On the Query Design toolbar, click the Run button , and then compare your screen with Figure 2.30.
Seventeen records display, including the records for donors who pledged exactly $25. Thus, the displayed records include pledges equal to or greater than $25. In this manner, comparison operators can be combined.
At the far right of the menu bar, click the Close Window button . Click Yes to save changes to the query. Then in the Save As dialog box and using your own name, type 2A Pledges $25 or More Firstname Lastname as the query name. Click OK or press to display the Database window.
The Between . . . And operator is a comparison operator that looks for values within a range. It is particularly useful when you need to locate records that are within a range of dates, such as the pledges collected between October 14 and October 20.
Be sure the Queries object button is selected. Click your 2A Pledges $25 or More query, and then on the Database window toolbar, click Design . From the Pledges field list, double-click Date Collected to add this field to the design grid.
On the Criteria row, under Pledge Amount, delete the existing criteria. On the Criteria row, under Date Collected type Between 10/14/07 And 10/20/07 and then press . Compare your screen with Figure 2.31, which has been widened to fully display the criteria.
This criteria instructs Access to look for values in the Date Collected field that begin with 10/14/07 and end with 10/20/07. Both the beginning and ending dates will be included in the query results. Access places # symbols around both dates, which identifies these values as dates. If you type the operators between . . . and, using lowercase letters, Access will capitalize the first letter of each operator.
NoteWidening Columns in the Query Grid
Widen a column in the design grid using the same techniques that are used in a table. In the selection bar at the top of the column, point to the right border and double-click to expand the column to fully display the contents on the criteria row. You can also drag the right border to the width you want.
Run the query and notice that nine pledges were collected between the dates you specified in your criteria.
From the File menu, click Save As. In the Save As dialog box, type 2A Collections from 10/14 through 10/20 Firstname Lastname as the query name, and then click OK. Close the Query window.
Chapter One. Creating Documents with Microsoft Word 2003
Chapter Two. Formatting and Organizing Text
Chapter Three. Using Graphics and Tables
Chapter Four. Using Special Document Formats, Columns, and Mail Merge
Chapter One. Creating a Worksheet and Charting Data
Chapter Two. Designing Effective Worksheets
Chapter Three. Using Functions and Data Tables
Chapter One. Getting Started with Access Databases and Tables
Chapter Two. Sort, Filter, and Query a Database
Chapter Three. Forms and Reports
Chapter One. Getting Started with PowerPoint 2003
Chapter Two. Creating a Presentation
Chapter Three. Formatting a Presentation
Chapter One. Using Access Data with Other Office Applications
Chapter Two. Using Tables in Word and Excel
Chapter Three. Using Excel as a Data Source in a Mail Merge
Chapter Four. Linking Data in Office Documents
Chapter Five. Creating Presentation Content from Office Documents
GO! with Microsoft Office 2003 Brief (2nd Edition)
The New Solution Selling: The Revolutionary Sales Process That Is Changing the Way People Sell [NEW SOLUTION SELLING 2/E]