Create Calculated Fields in Microsoft Access Select Queries
by Avantix Learning Team | Updated September 18, 2020
Applies to: Microsoft® Access® 2010, 2013, 2016, 2019 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
Creating 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):
- Click the Create tab in the Ribbon and then click Query Design in the Queries group.
- Double-click the desired tables and then click Close.
- 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.
- 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.
- 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.
- If you are in the Zoom dialog box, click OK.
- Press Enter.
- 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:
A calculated field in Design View in a query may appear in the Field row as follows:
These calculations are not case sensitive so you could also enter:
Creating a calculated field using the Expression Builder
To create a query with a calculated field using the Expression Builder:
- 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 (:).
- 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.
- Continue entering the desired formula.
- Click OK.
- Press Enter.
- 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:
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.
Did you find this article helpful? If you would like to receive new articles, join our email list.
Recommended Microsoft Access training
Our instructor-led classroom training courses are delivered at our downtown Toronto location at 1 Yonge Street, Suite 1801 (Toronto Star Building), Toronto, Ontario. Contact us if you’d like to arrange custom training at your office on a date that’s convenient for you.
To request this page in an alternate format, contact us.
Copyright 2020 Avantix® Learning
You may also like
You can highlight values in fields or records in Microsoft Access reports using conditional formatting. Certain conditions must be met in order for the formatting to be applied …
Check out these great shortcuts for manipulating controls in Design View in both forms and reports in Microsoft Access.
In Microsoft Access, small green error markers may appear in Design View in forms and reports for a number of reasons. You can turn error checking off completely or set the rules you prefer.
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 | 1 Yonge Street, Suite 1801 (Toronto Star Building), Toronto, Ontario, Canada M5E 1W7 | firstname.lastname@example.org