Create Calculated Fields in Microsoft Access Select Queries

by Avantix Learning Team | Updated October 14, 2022

Applies to: Microsoft® Access® 2010, 2013, 2016, 2019, 2022 and 365 (Windows)

You can create calculated fields in select queries in Microsoft Access in the QBE (query by example) grid. You'll need to learn a few syntax rules and then you can create simple to more complex calculations. Calculated fields can also be created in other types of Access queries.

Recommended article: 10 Microsoft Access Tips for Working with Select Queries

Create a calculated field in a select query

To create a select query with a calculated field (which would appear in each record in Datasheet View):

  1. Click the Create tab in the Ribbon and then click Query Design in the Queries group.
  2. Double-click the desired tables and then click Close.
  3. In the grid, in a blank column in the Field row, enter the new field name followed by a colon (:). Anything after the colon is part of the mathematical expression used in the field. When you enter the name of the new field, do not use periods (.), square brackets ([]) or exclamation marks (!). Also, do not use the same name as another field in a table in your database.
  4. After the new field name and the colon, enter the expression. When you enter field names in the expression, they should appear in square brackets such as [actualsales]. You can right-click in the field row and select Zoom or press Shift + F2 to "zoom in" to make it easier to enter the expression. For example, you could enter Variance:[actualsales]-[projectedsales] in the field row or Zoom dialog box.
  5. In the expression, enter any operators or functions as appropriate (+ for addition, – for subtraction, / for divide and * for multiply). You can also enter Access functions.
  6. If you are in the Zoom dialog box, click OK.
  7. Press Enter.
  8. Right-click the tab for the query and select Datasheet View. You can also click Run in the Results group in the Query Tools Design tab in the Ribbon.

In order for these calculations to work, the fields that you include in the expression should be fields in the displayed tables. Also, watch out for typing errors. Actual Sales is different from ActualSales and square brackets, not round brackets, are used to enclose the fields.

Below is the Zoom dialog box:

Zoom dialog box in Microsoft Access to help enter a calculated field in a query.

A calculated field in Design View in a query may appear in the Field row as follows:

Variance:[ActualSales]-[ProjectedSales]

These calculations are not case sensitive so you could also enter:

Variance:[actualsales]-[projectedsales]

Create a calculated field using the Expression Builder

To create a query with a calculated field using the Expression Builder:

  1. In Query Design View, in the grid, click in a blank column in the Field row and then enter the new field name followed by a colon (:).
  2. Click Builder in the Query Setup group in the Query Tools Design tab in the Ribbon or press Ctrl + F2. The Expression Builder appears. Enter the expression or click the + beside Functions and then click Built-In Functions to view the functions available in Access.
  3. Continue entering the desired formula.
  4. Click OK.
  5. Press Enter.
  6. Right-click the tab for the query and select Datasheet View. You can also click Run in the Results Area in the Query Tools Design tab in the Ribbon.

Below is the Expression Builder:

Microsoft Access Expression Builder to create calculated fields in a query.

You can create all kinds of basic and more complex calculations using the functions in Microsoft Access not only in queries, but in forms, reports and other objects. We'll be showing some of the other calculations you can create in future articles.

Subscribe to get more articles like this one

Did you find this article helpful? If you would like to receive new articles, JOIN our email list.

More resources

Key Features and Benefits of Microsoft Access

How to Filter a Report on the Fly in Microsoft Access

10 Tips for Creating Select Queries in Microsoft Access

10 Techniques for Designing Forms in Microsoft Access

How to Convert a Microsoft Access Report to PDF (3 Ways)

Related courses

Microsoft Access: Introduction

Microsoft Access: Intermediate / Advanced

Microsoft Access: Introduction to VBA (Visual Basic for Applications)

VIEW MORE COURSES >

Our instructor-led courses are delivered in virtual classroom format or at our downtown Toronto location at 18 King Street East, Suite 1400, Toronto, Ontario, Canada (some in-person classroom courses may also be delivered at an alternate downtown Toronto location). Contact us at info@avantixlearning.ca if you'd like to arrange custom instructor-led virtual classroom or onsite training on a date that's convenient for you.

Copyright 2023 Avantix® Learning

You may also like

How to Combine First and Last Name in Excel (5 Ways)

How to Combine First and Last Name in Excel (5 Ways)

You can combine first and last name in Excel in several ways – using the CONCATENATE operator, the CONCATENATE function, the CONCAT function, the TEXTJOIN function or Flash Fill. These functions are often used to combine text in cells but you can also combine text with spaces, commas, dashes or another character. It's common to combine first and last names that appear in two columns into one new column. Some functions are only available in newer versions of Excel but the CONCATENATE operator and function are available in all versions.

How to Insert Multiple Columns in Excel (4 Fast Ways with Shortcuts)

How to Insert Multiple Columns in Excel (4 Fast Ways with Shortcuts)

You can quickly insert multiple columns in Excel using a drop-down menu, keyboard shortcuts or the Home tab in the Ribbon. The key to inserting multiple columns at once, rather than one by one, is to select the number of columns you want to insert first and then insert columns. Excel will insert the same number of columns you selected.

Excel XLOOKUP Function (Overview, Syntax + Formula Examples)

Excel XLOOKUP Function (Overview, Syntax + Formula Examples)

The XLOOKUP function is a replacement for Excel's traditional VLOOKUP function (as well as HLOOKUP and INDEX / MATCH functions). It has a new set of arguments and is available in Excel 2021 and 365. It allows you to look up a value from an array in a range or table and return one or more results. One of the primary benefits of XLOOKUP is that it can look up from columns to the left in a data set and return a range.

Microsoft, the Microsoft logo, Microsoft Office and related Microsoft applications and logos are registered trademarks of Microsoft Corporation in Canada, US and other countries. All other trademarks are the property of the registered owners.

Avantix Learning |18 King Street East, Suite 1400, Toronto, Ontario, Canada M5C 1C4 | Contact us at info@avantixlearning.ca

Summary
How to Create a Calculated Field in a Microsoft Access Query
Article Name
How to Create a Calculated Field in a Microsoft Access Query
Description
You can create calculated fields in select queries in Microsoft Access in the QBE (Query by Example) grid. You'll need to learn a few syntax rules and then you can create simple to more complex calculations.
Author
Publisher Name
Avantix Learning

Pin It on Pinterest

Share This