Recently a couple of my SQL Server Reporting Services clients have asked, how can they add a page break after a specific number of records in a tablix object.
To give them a bit more flexibility I decided to add a parameter, that allowed them to change the number of records per page
Solution:
- Create a new report, and the required datasource and dataset
- Create a Parameter field:
- General -
Name: NoRecords Prompt: Enter No of Records Per Page Data Type: Integer Select Parameter Visibility: Visible
- Default Values -
Specifiy Value - Value 25
- Add a Tablix object to the canvas
- Add the required fields to the tablix
- Click on any cell in the tablix
- Right Click on the Detail Row selection button
- Select Add Group - Row Group - Parent Group
- In the Tablix Group dialog box, in the Group By expression box, enter:
=CEILING(RowNumber(Nothing)/Parameters!NoRecords.Value)
- Press the OK button
This adds a Group 1 section to the tablix, and in the Row Group Section at the bottom of the screen
- In the Row Groups section at the bottom of the screen, select the down arrow of Group 1
- Select the Group Properties
- In the Group Properties dialog box:
- General - Name: Page_Break_Group
- Page Breaks - Between each instance of a group
- Sorting - Select the Sort expression column and press the Delete button
- Press the OK button
- On the tablix, Right click the Group 1 column
- Select Delete Columns
- in the Delete Columns dialog box, select the Delete Columns only
- Press the OK button
The report now only displays 25 records per page, but will change based on the value entered in the parameter
If you have any questions, leave us a comment below, or need any assistance, please do not hesitate to Contact Us |