Share via

Subreport Visibility issue

Anna 21 Reputation points
2021-11-15T19:42:47.99+00:00

I have a report with a subreport.
Wherein the main report passes a parameter to the subreport and displays the associated record.
Each unique record in the main report returns a subreport. When there is no record in the subreport i want to display either a message saying no records found or not display anything at all.
The issue is that when a record in the main report have no subreport data it displays "Error displaying subreport". I dont want this error to display. I played with the subreport visibility using IIF(countrows("dataset")=0,false,true) but it doesnt seem to work, it doesnt display the subreport even if there is data and the ones the has no data still have the error message.

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.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Joyzhao-MSFT 15,651 Reputation points
    2021-11-16T01:55:04.753+00:00

    Hi @Anna ,

    when a record in the main report have no subreport data

    Do you mean that the parameter passed by the main report to the subreport is null(the subreport has this parameter, but the value is NULL), or is the parameter missing in the subreport? I think these are two different concepts. Your expression should only apply to the former, that is, the parameter is also exists in the subreport, but the parameter is null. In the latter case, the report will not be rendered correctly.

    As I said before: In Report Designer, all parameters that are required by the subreport must be included in the Parameters list. If a required parameter is missing, the subreport is not displayed correctly in the main report. Consider the following scenario, the available values for sub report parameter contains val1, val2 and val3. If you pass a val4 from main report to call the sub report, it will prompt the Error: Subreport could not be shown.

    For more information, please refer to: Add a subreport and parameters to a paginated report (Report Builder).
    If I misunderstand what you mean, please feel free to let me know.
    Best Regards,
    Joy


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

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