In This Topic
C1Report field objects have a RunningSum property that makes it easy to maintain running sums over groups or over the entire report.
Adding Running Sums over a Group
To keep running sums over groups, complete the following tasks:
- Open the C1ReportDesigner application. For more information on how to access the C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.
- Create a new report or open an existing report. Once you have the report in the C1ReportDesigner application, you can modify the report properties.
- Click the Design button to begin editing the report.
- In Design mode, select the report from the drop-down list above the Properties window. The available properties for the report appear.
- Add a calculated field to the report:
- Click the Add Calculated Field button from the Designer toolbar.
- In the VBScript Editor, enter the following script:
Sum(ProductSalesCtl)
- Drag the mouse over the GroupHeader section of the report and the cursor changes into a cross-hair . Click and drag to define the rectangle that the new field will occupy, and then release the button to create the new field.
-
Set the RunningSum property to SumOverGroup. (Note that for this property to appear, the properties filter must be turned off. It's the funnel icon above the Properties window.)
Adding Running Sums over the Entire Report
To keep running sums over pages, you need to use script. For example, you could add a pageSum field to the report and update it with script. To do this, complete the following tasks:
- Open the C1ReportDesigner application. For more information on how to access the C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.
- Create a new report or open an existing report. Once you have the report in the C1ReportDesigner application, you can modify the report properties.
- Click the Design button to begin editing the report.
- In Design mode, select the report from the drop-down list above the Properties window. The available properties for the report appear.
- Locate the OnPage property and click the empty field next to it, and then click the ellipsis button.
- The VBScript Editor appears. Enter the following VBScript expression in the code editor:
' VBScript: Report.OnPage
pageSum = 0
-
Then select Detail from the drop-down list above the Properties window. The available properties for the Detail section appear.
-
Locate the OnPrint property and click the empty field next to it, and then click the ellipsis button.
-
The VBScript Editor appears. Enter the following VBScript expression in the code editor: ' VBScript: Detail.OnPrint
pageSum = pageSum + UnitsInStock
Note: For the complete report, see report "17: Running Sums" in the CommonTasks.xml report definition file, which is available in the ComponentOne Samples folder.