TECH TIP: Forcing a Page Break
Question: “How can I force a page break occur based upon a condition calculated at run-time.”
The latest versions of ReportBuilder include a TppPageBreak component which may be placed anywhere inside a report and automatically force a page break. This is the recommended method for forcing a page break in ReportBuilder. Below are other (older) methods for performing the same task.
Solution 1:
Define a Group that starts on a new page when it breaks. Then use the Group.OnGetBreakValue
event to control the timing of the break.
- From the Report Designer, select Report | Groups to access the Group dialog.
- Define a group based upon a static component, such as a Label or Variable. Click the Start new page checkbox. Close the dialog.
- Using the object inspector’s drop down list, find and select the TppGroup object.
- Create an event-handler for the Group’s OnGetBreakValue event.
- Add code to set the break value.
Solution 2:
- Place a subreport at the point where you might want a page break.
- Remove its summary band and reduce the height of its detail and title bands to zero.By programmatically setting the title band’s NewPage property you can conditionally force a page break. Note that everything after the subreport that is in the same band with it will need to ShiftRelativeTo the subreport.