Office 2007 - Access

Lesson 23: Query Criteria

23/72 Lessons 

Add “Criteria” to a “Query”

One of the reasons why we use a “Query” is to get answers to questions.

For example, the “Query” that we had made in previous lesson gave me all the results of all students, of all subjects.

Suppose you want only those with the “excellent” grade to be seen in the results?

To answer this question, we need to add criteria to the “Query”.

To do this, open the “Query” in “Design View”.

In the “Criteria” row under the “Grade” column, type the criteria that the data in the field must meet. We do not need to type the quotes, they are added automatically.

Click the “Run” button in the “Ribbon”.

“Access” will display only those records that meet this criteria.

A second question is, for example, which of the students have a score less than 60?

For this, remove the criteria from the “Grade” column and type <60 in the criteria row under the “score” column.

Result:

Logical operators

Obviously, we can enter multiple criteria in our “Query”.

Criteria entered on the same line are considered as an AND operator.

This means that the data in the record must meet both criteria.

When we insert different criteria on different lines, it is regarded as an OR operator. Which means that the data in the record, must meet atleadt one of these criteria.

For example:

In the example above, if I had two criteria on the same line, I would’ve had little result. Indeed, there are no “excellent” assessments when the score is below 60.

Result:


However, when the criteria is placed in different rows instead, I get all records where the grade is “excellent”, or the score is less than 60.


Result:

So make sure that when you have different criteria on the same line, the criteria is a meaningful.

When you use different criteria on different lines, the criteria is for complying with any one of them.

Awesome!
You've completed Lesson 23
START NEXT LESSON