Access Tutorial - Creating Queries


Covered in this section:

  1. Using Queries to Create Calculated Fields
  2. Queries Using a Filter
  3. Creating Complex Queries

Using Queries to Create Calculated Fields

Access is capable of performing calculations like Excel. However, Access only supports calculations in queries.

Open the Database window and click on Queries under Objects.

Double click on Create query in Design view.

Two windows will pop up the Show Table and the Select Query window The Show Table window allows you to select the tables that you will use.

Highlight student and click on Add.

If you have more tables to be inserted, select those tables and click on Add. When you’re done, click on Close.

We'll keep it simple and stick to one table per database.

  Double click on the field names in the small student menu to show them in the Query.

In the student table window double click on Name, Class Name, Student #, and Test Mark for now.

Now move to the next available empty column and click on the build icon in the main toolbar. The build icon starts the Expression Builder that you will use when you want to add a calculation to a query.

The Expression Builder allows you to calculate a value that will appear in the query results. The top half shows the formula, the bottom half lets you select which fields to insert into the formula. In this example, double click on Tables and then click on student. Now in the middle bottom space you will see all the fields that are in the student table. Double click on Test Mark field, then select the / operator, then double click on the Max Score field, then the * operator and finally type in 100. Now click OK.

You should be seeing the following:

The column where you put in the formula will look like the image on the left. Scroll back to the very beginning to change Expr1: to Test Grade:. Do not forget the colon after Test Grade or else the expression will not work.

Click on the Run icon, to build this Query.

You should end up with something like this:

To format the calculated fields to have only a certain number of decimal places, open your query in design view. Then select the field you wish to format by clicking on it. Now click the Properties icon in top tool bar.

You should have opened the Field Properties window. Within this window change Format to "Fixed" by clicking on the Format option and using the drop down menu. Now switch the Decimal Places by clicking on the Decimal Places option and using the drop down menu.

Exercise: