Glossary Item Box
In ActiveReports, summary fields can be added to any section to calculate totals, counts, averages and other aggregations. The summary field's placement dictates when the section containing the field, and sections after it, will be printed. A section with a summary field will be delayed until all the calculations are completed. This allows summary fields to be placed ahead of the corresponding detail.
Summary fields are calculated according to the textbox's Summary properties. A summary textbox is updated with each new detail record. When a field is placed ahead of the Detail section (i.e. in the ReportHeader, PageHeader or GroupHeader sections), the Detail section is formatted with each record and the summary field is updated. When all records for the summary level are read, the header section is printed followed by the delayed sections.
This walkthrough illustrates how to create a report with a summary field in the GroupFooter section.
This walkthrough is split up into the following activities:
To complete the walkthrough, you must have access to the NorthWind database (Nwind.mdb).
When you have completed this walkthrough, you will have a report that looks similar to the following.
To add an ActiveReport to your project
To connect the report to a data source
To add controls to the report
Control | Name | Text/Caption | Location |
---|---|---|---|
Label | lblProductID | Product ID | 1.208, 0 |
Label | lblProductName | Product Name | 2.489, 0 |
Label | lblUnitPrice | Unit Price | 4.56, 0 |
Label | lblOrderDate | Order Date | 0, 0 |
Control | DataField | Name | Text/Caption | Location | Output Format |
---|---|---|---|---|---|
TextBox | products.ProductID | txtProductID | Product ID | 1.218, 0 | (Empty string) |
TextBox | ProductName | txtProductName | Product Name | 2.5, 0 | (Empty string) |
TextBox | OrderDate | txtOrderDate | Order Date | 0, 0 | (Empty string) |
TextBox | products.UnitPrice | txtUnitPrice | Unit Price | 4.562, 0 | Currency |
Control | DataField | Name | Text/Caption | Location | Misc Details |
---|---|---|---|---|---|
Label | (Empty string) | lblSalesTotal | Daily Sales Total | 3, 0 | (Empty string) |
TextBox | products.UnitPrice | txtSalesTotal | Sales Total | 4.562, 0 | OutputFormat = Currency
SummaryType = SubTotal SummaryRunning = Group SummaryGroup = ghOrders |
Label | (Empty string) | lblWhiteLine | (Empty string) | 0, 0.25 | Background color = white |
Note Distinct summarization can be used in a situation when the field's value repeats in several detail records and the summary function needs to include a single value from all repeating values. To do this, you would need to set the DistinctField property of the summary field to the appropriate value and set the SummaryFunc property to the appropriate distinct summary function.
To view the report
See Also |
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.