Office 2007 - Access

Lesson 27: Wildcards and “IF” Functions

27/72 Lessons 

“Wildcards”

We use “Wildcards” in a query when we’re not sure of the spelling of text or numbers in a field.

When I have an asterisk character (*) after a number of letters that I typed into the “Criteria” field, “Access” will display all fields that begin with these letters, when I run the “Query”.


When I place an asterisk before and after a few letters that I typed into the “Criteria” field, “Access” will display all the fields in which these letters appear in that order.

Another “Wildcard” is the question mark (?).

The question mark replaces a single letter or digit.
For example, find the words Aarts and Aerts .
We use the two “Wildcard” characters together, as in this example, when we run the query “Access” will try to find all customers with this name, regardless of the name.

IF function

The IF function gives us different values, depending on the evaluation of the expression.

If the evaluations results in “true”, then it gives one value. If the evaluation was “false”, it gives a different value.

An example.

Depending on the result in “Query” below, I give “Pass” the students for each test when they score more than 55. If it is less, then I give them the “Fail” value.

Open the “Query” in “Design View”.

Right-click an empty square in the grid, and select “zoom in / out”.

This opens the “Zoom” dialog
The name that we are going to give this field is “Status”. So I begin the expression with the word “Status”, followed by a colon.
Then you type IF function which is written in the below format
The IF function consists of three parts, the expression, value if true and value if false.
These three parts must be enclosed in parentheses and must be separated by a coma (,).
The two values (fail / pass) should be in quotes only if they consist of text, not when they consist of numbers.
The name of the field on which the expression is evaluated must be enclosed in square brackets.

So if I follow all these rules, I have something like this:
Status: If ([score] <55, “fail”, “pass”)
So it is:
if the “score” is less than 55 then he / she failed, else he / she passed the test.
Click the OK button

You do not necessarily have to type in this dialog, you can also type directly in the field, but you better watch  what you type.

Click the “Run” button in the “Ribbon” when you’re done.

Awesome!
You've completed Lesson 27
START NEXT LESSON