Therefore, a total field is similar to a Function control because both are evaluated when the report is generated. But there are some differences: a Function control can only be placed in a group footer, and a total field can be placed in any part of the data Report Designer, excluding the report Header/footer and the page header section.
Another difference is in how two fields are created: Although a Function control is a feature of the Data Report Designer, the aggregate field is a feature of the Data Environment designer. To add a total field to a report, the steps are:
- Create a total field in the Data Environment designer.
- From the Data Environment Designer, drag the Totals field onto the Data Report Designer.
As an example, the following illustration shows a total field showing the number of ordered products.
Data report with an aggregate field
Using a Function control can be more efficient than using a total field. When a data report evaluates a value for a Function control, it takes a certain amount of processing to create each value. When the data environment creates an aggregate field, it spends a similar amount of processing. However, you can save processing time by using a Function control, because the Data Report Designer must create the entire report in its own processing.
Note This topic is part of a series of steps that help you create a sample data report. Creating a simple Data report is the first topic in this series.
to create a total field in the data environment, follow these steps:
- On the Data Environment designer, open the Detail Fields in Customers folder, right-clickOrders, and then click Properties.
- In theOrders Propertiesdialog box, click the Totals tab.
- Click the Add button.
- Click the Name box and type "productcount".
- In the Functions combo box, selectCNT.
- In the Totals combo box, selectOrderDetails(the default should be checked).
- In the field combo box, selectProductID.
- Click OK to close the dialog box.
Now that you have created the total field, you can put it in the Data Report Designer.
to add a total field to a data report, follow these steps:
- From the Data Environment Designer, drag theproductcounttotal field to the group named "Orders_header."
- Change the Label control's Caption to "Product (s) Ordered."
- Reposition and resize the TextBox and Label controls so that they resemble the following illustration:
- Save and run the project.