{"id":4567,"date":"2024-02-29T15:27:52","date_gmt":"2024-02-29T15:27:52","guid":{"rendered":"https:\/\/himbap.com\/blog\/?p=4567"},"modified":"2024-02-29T15:27:52","modified_gmt":"2024-02-29T15:27:52","slug":"hiding-subreport-text-box-in-main-report","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=4567","title":{"rendered":"Hiding Subreport Text box in Main Report"},"content":{"rendered":"<p><strong>Requirement<\/strong><br \/>\nAs 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&#8217;ll explore how to hide a textbox within a subreport based on parameter.<\/p>\n<p><strong>Understanding the Scenario<\/strong><br \/>\nLet&#8217;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.<br \/>\nYou 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.<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4588 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS1-300x120.png\" alt=\"SSRS1\" width=\"300\" height=\"120\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS1-300x120.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS1-1024x410.png 1024w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS1-624x250.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS1.png 1265w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I have added SubReport to main report like below<\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4589 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS2-300x166.png\" alt=\"SSRS2\" width=\"300\" height=\"166\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS2-300x166.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS2-1024x566.png 1024w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS2-624x345.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS2.png 1261w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now when we will run our MainReport, we will see the text box we added in the sub report like below:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS5.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4596 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS5-300x144.png\" alt=\"SSRS5\" width=\"300\" height=\"144\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS5-300x144.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS5-624x299.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS5.png 948w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now in order to hide text box in the SubReport, let&#8217;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.<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS3.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4590 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS3-300x151.png\" alt=\"SSRS3\" width=\"300\" height=\"151\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS3-300x151.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS3-1024x517.png 1024w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS3-624x315.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS3.png 1104w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now we need to set default value as name of the report so for example in the main report parameter value will be &#8220;MainReport&#8221;<\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS4v11.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4595 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS4v11-300x202.png\" alt=\"SSRS4v1\" width=\"300\" height=\"202\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS4v11-300x202.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS4v11.png 560w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Finally to hide this text box, we need to following two steps:<br \/>\n<strong>Add Expression to text box<\/strong><br \/>\nIn the SubReport, we need to edit text box properties and add expression to hide show text box like below:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS6.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4597 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS6-300x203.png\" alt=\"SSRS6\" width=\"300\" height=\"203\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS6-300x203.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS6-1024x693.png 1024w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS6-624x422.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS6.png 1253w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Above expression will checking value of the parameter and based on that it will hide\/show text box.<br \/>\n<strong>Pass Parameter to SubReport<\/strong><br \/>\nNow we need to pass ReportName parameter from Main report to Subreport like below:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS7.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4598 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS7-300x129.png\" alt=\"SSRS7\" width=\"300\" height=\"129\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS7-300x129.png 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS7-624x268.png 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2024\/02\/SSRS7.png 1005w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now when we will run our MainReport, we won&#8217;t see text box anymore<\/p>\n<p><strong>Summary<\/strong><br \/>\nWe 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.<\/p>\n<p>Hope it will help someone !!<br \/>\n<strong>Keep learning and Keep Sharing !!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Requirement 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&#8217;ll explore how to hide a textbox&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=4567\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":4597,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[21],"tags":[862,1081,1079,1080,1078],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4567"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4567"}],"version-history":[{"count":7,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4567\/revisions"}],"predecessor-version":[{"id":4601,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4567\/revisions\/4601"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/4597"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}