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

前端 未结 3 988
猫巷女王i
猫巷女王i 2020-12-06 13:57

I have an issue where I wish to hide/show a sub-report based on a parameter that is passed to the main report.

I can set the hidden property using an expression whic

相关标签:
3条回答
  • 2020-12-06 14:47
    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.

    0 讨论(0)
  • 2020-12-06 14:49

    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).

    0 讨论(0)
  • 2020-12-06 14:59

    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.

    0 讨论(0)
提交回复
热议问题