Office 2010 - Access

Lesson 25: Query Criteria

25/76 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 made in previous lessons 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 do this we need to add criteria to the “Query” by opening the “Query” in “Design View”. In the “Criteria” row under the “Grade” column, type the value that this field must have. You do not need to type the quotes, they are added automatically .

les25_image001_en
Click the “Run” button in the “Ribbon”.
“Access” will only display records that meet this criteria.

les25_image002_en

Another question my be, “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.

les25_image003_en

Result:

les25_image004_en

 

Logical operators

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 atleast 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.

les25_image005_en

Result:

les25_image006_en

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

les25_image007_en

Result:

les25_image008_en

So make sure when you have different criteria on the same line, only when you want all the criteria to be met with. When you use different criteria on different lines, any one of criteris should be met.

Awesome!
You've completed Lesson 25
START NEXT LESSON