How do I get a subreport on just the last page of an SSRS report with generating a blank page when it has no results?

Kyle Coleman 20 Reputation points
2023-09-19T18:10:25.67+00:00

We have an Electronic Health Record Service with a report that displays patient health screens with page breaks between each patient.

A subreport was added outside this group to display all patients who do not have a health screen saved in our system based on the parameters passed to the initial report. We want this report to be displayed on its own page(s) after the initial dataset. We've done this by checking the 'also at the end' page break option.

We've found that when there's no result set returned from SQL (as happens depending on the parameters passed) we still get a blank page and have found no alternate way of getting the subreport on it's own page.

We're wondering if there's a way to disable the 'also at the end' page break option only if there are no results in the subreport.

I don't know if this will be helpful but here's a mockup for the visual:HealthScreenMockup

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,912 questions
0 comments No comments
{count} votes

Accepted answer
  1. AniyaTang-MSFT 12,441 Reputation points Microsoft Vendor
    2023-09-20T02:32:07.04+00:00

    Hi @Kyle Coleman

    I think you can put the subreport in a rectangle and then control the pagination of the subreport through the rectangle.

    I did a simple test, created a subreport placed in a rectangle, and created a parameter Product to pass the parameters.

    Screenshot 2023-09-20 102522

    Then in the rectangle's PageBreak property, set the value of BreakLocation to "Start". Then use an expression in the value of Disabled, that is, when the parameter is empty, the page break is disabled, otherwise the page break is enabled.

    Screenshot 2023-09-20 102556

    Preview:

    Last page when subreport has no results:

    Screenshot 2023-09-20 102815

    Last page when the subreport has results:

    Screenshot 2023-09-20 102835

    If the answer is helpful, please click Accept Answer and Up-Vote for the same. If you have any questions, please feel free to let me know.

    Best regards,

    Aniya

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.