Hiding Sub report in SSRS based on Parameter (and not executing the Stored Procedure)

你离开我真会死。 提交于 2019-11-28 00:29:35

Hidden report elements in SSRS are still processed - the hidden property simply determines whether they are displayed in the output.

One way to ensure that the procedure is only executed conditionally would be to change the name of the stored procedure in the dataset to an expression - something like:

=iif(Parameters!RunMyDataset.Value="Y","sp_MyDataSet","sp_Dummy")

- where sp_Dummy is a stored procedure that performs minimal processing (eg. SELECT NULL).

There's a method to solve this. Base on your description of the question. For example, you have 4 subreports and named them page1 through page4. And main report will pass a parameter "Investor_ID" value to all these 4 pages. In the main report, you need to create 4 boolean parameters and set hidden property of the subreport to control these 4 subreports visible or not.

For instance, Use expression =iif(Parameters!Page1.Value = true, false, true) so that when you select true for parameter page1 then page1 will be shown otherwise it will be hidden.

Then you need to config parameters in "Subreport Properties" for subreports.

For Parameter Investor_ID, which the subreport needed, in the value choose expressing and use =IIF(Parameters!Page1.Value = true, Fields!Investor_ID.Value, nothing). That means if you choose hide page1 then mainreport will pass nothing to subreport page1. Then Page1 will not be run and will show "Error: Subreport could not be show" since the Investor_ID parameter is null. But we hide that subreport. So page1 will not show up.

In this way you can control the hidden subreport execute or not.

  1. Right-click on the sub report object in the main report and select “Format Subreport…”. This will open the Format Editor.

  2. Select the “Subreport” tab in the Format Editor.

  3. place a check mark in the “Suppress Blank Subreport” check box.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!