This tutorial demonstrates how the number of records shown in a report can be limited by means of conditional formatting. In particular, a formatting rule is applied to the Visibleproperty of the Page Breakcontrol. In this example, the number of data rows is passed to the report as a parameter.
To limit the number of records per page, follow the instructions below.
-
Create a new report or open an existing one. In this example, a data-aware table reportis used as a starting point.
-
To add a parameterto the report, in the Field List, right-click the Parameterssection, and in the invoked menu, choose Add Parameter.
-
For the created parameter, set the (Name)property to rowsNumber, Parameter Typeto Int32and Descriptionto Rows per Page:.
-
From the Toolbox, drop the Page Breakcontrol onto the report's Detailband and place it at the top of the detail table.
-
For the created control, set the Visibleproperty to No, and for its Formatting Rulesproperty, click the ellipsis button, to invoke the Formatting Rules Editor.
In this dialog, click the Edit Rule Sheet...button. The Formatting Rule Sheet Editorwill appear.
-
Now, click , to create a new formatting rule. Then, set its Visibleproperty to Yes, and for the Conditionproperty, click the ellipsis button, to invoke the Condition Editor.
-
In this editor, define the following expression for the rule: ([DataSource.CurrentRowIndex] % [Parameters.rowsNumber] == 0) And ([DataSource.CurrentRowIndex] != 0).
Click OK, to save the changes and close the dialog. Then, click Closeto quit the Formatting Rule Sheet Editor.
-
Now, in the Formatting Rules Editor, you can see the created rule, which should be moved to the list of applied rules on the right, using the arrow buttons in the middle of the dialog.
To close the editor, click OK.
The report is now ready. Switch to the Preview Tab, and in the Parameterssection, define the required value and click Submit.
See Also