Hiding Subreport Text box in Main Report

As a SQL Server Reporting Services (SSRS) developer, you often encounter scenarios where you need to customize the visibility of elements like text boxes within subreports based on certain parameters. This kind of dynamic behavior enhances the user experience and ensures that reports are tailored to specific requirements. In this blog post, we’ll explore how to hide a textbox within a subreport based on parameter.

Understanding the Scenario
Let’s imagine a scenario where you have two reports, subreport and main report. There is a text box on the subreport which we only want to show when rendered in the subreport but while this subreport is used in the main report we want to hide this text box, let see how we can do that using parameter.
You can see in the below screenshot I have two report SubReport and MainReport, In the SubReport I have added a text box I want to hide this when this will render in the main report.

I have added SubReport to main report like below


Now when we will run our MainReport, we will see the text box we added in the sub report like below:

Now in order to hide text box in the SubReport, let’s add a parameter named ReportName in both the report and we will keep this parameter hidden as we are going to set default value to this parameter.

Now we need to set default value as name of the report so for example in the main report parameter value will be “MainReport”


Finally to hide this text box, we need to following two steps:
Add Expression to text box
In the SubReport, we need to edit text box properties and add expression to hide show text box like below:

Above expression will checking value of the parameter and based on that it will hide/show text box.
Pass Parameter to SubReport
Now we need to pass ReportName parameter from Main report to Subreport like below:

Now when we will run our MainReport, we won’t see text box anymore

We learned how to utilize parameter in SSRS to hide/show text box. By following the steps outlined in this blog post you can effectively control the visibility of elements within SubReports using parameter, enhancing the usability and effectiveness of your SSRS reports.

Hope it will help someone !!
Keep learning and Keep Sharing !!

Leave a Reply

Your email address will not be published. Required fields are marked *