Adding a Calculated Control to a Report Section
A calculated control is a text control that uses an expression to calculate a value based on other values in the report. Create a calculated control by adding an unbound text control to the report. Type the expression to be calculated in the text control.
To add a calculated control:
- Add a new unbound text control to the report by clicking the Text Box button in the Toolbox. Click the place in the report where you want the new control to appear.
- Change the label text by right-clicking on the label and selecting Properties. Type the new label text in the Caption: box. Close the properties dialog by clicking the close box in the upper right corner.
- Click the text control box once to select it, then click again and type the expression to be calculated. Be careful not to double-click.
- Start the expression with the = sign.
- If your expression includes a function like SUM or COUNT, be sure to include parentheses around the values. For example, the expression =SUM([TotalOrders]) would calculate the total of all the total orders fields.
- If your expression includes field names, be sure to enclose the field name in brackets. For example, =[ProductsOrdered]-[ProductsSold] would calculate the value of the ProductsOrdered field minus the ProductsSold field.
- Press Enter when you are finished typing the expression.
- Switch to Preview view to see the results of the new calculated control.
Use the Expression Builder to create complex expressions.
Which part of the report you add the calculated control to determines which fields it can calculate. For example, you can add a calculated control that displays totals or averages for all records in the report to the report footer since the footer references all records. To add a calculated control that figures a value based on values that are specific to each record, place the control in the details section.
Common calculated controls include these functions:
- SUM To calculate the total value of a field for all the records in the report
- AVG To calculate the average value of a field for all records in the report
- COUNT To calculate how many records there are in each group in the report
- MIN To calculate the minimum value of a field or all records in the report
- MAX To calculate the maximum value of a field for all records in the report