[英]how to use a same parameter as a drop down and text box based on previous parameters in SSRS?
I have a report which has 3 parameters. 我有一个包含3个参数的报告。 Two date parameters which can accept NULL. 两个可以接受NULL的日期参数。 The third parameter should always be entered for the report to display. 应始终输入第三个参数以显示报告。 I want the third parameter to act as a 'Textbox' so a user can enter values when the first 2 parameters are NULL. 我希望第三个参数充当“文本框”,以便用户可以在前两个参数为NULL时输入值。 When the first 2 parameters are not NULL, the third parameter becomes a Dropdown selection. 当前两个参数不为NULL时,第三个参数将成为下拉列表选择。
I have created a dataset for the third parameter to feed on based on the 2 parameters - 我已经基于2个参数为第三个参数创建了数据集-
IF @StartDate is NULL and @EndDate is NULL
select NULL as ID
IF @StartDate is not null and @EndDate is not NULL
select ID from table when date between @StartDate and @EndDate
When I run the report with date parameters NULL, third parameter displays a blank textbox, but when I enter a value - it just displays blank report. 当我使用日期参数NULL运行报告时,第三个参数显示一个空白文本框,但是当我输入一个值时-它仅显示空白报告。 It looks like the report query is not overwriting the NULL value selected. 看起来报表查询没有覆盖所选的NULL值。
When I enter any value in the Batch ID parameter and click on "View report", it just returns blank page with 3rd parameter blank. 当我在“批次ID”参数中输入任何值并单击“查看报告”时,它将仅返回空白页,其中第三个参数为空白。 NO report is being displayed. 没有报告正在显示。
Any ideas to approach this scenario are appreciated.Thank you 任何解决这种情况的想法都将受到赞赏。谢谢
You can't have the third parameter be both an open textbox AND a single select drop-down list. 您不能使第三个参数既是打开的文本框又是单个选择下拉列表。 You'll need a fourth parameter for this. 您将需要第四个参数。
The dataset you shared will work for the drop-down, but you will need to have a default value other than NULL. 您共享的数据集将对下拉列表起作用,但是您需要具有除NULL以外的默认值。 In the parameter properties, set the Available Values to pull from this dataset. 在参数属性中,设置“可用值”以从该数据集中提取。
Add a fourth parameter that is a textbox. 添加第四个参数是文本框。 Allow blank values. 允许空白值。
In your main dataset you will need to handle these parameters either in the query or as dataset filters. 在主数据集中,您将需要在查询中或作为数据集过滤器处理这些参数。 For example, the end of your query could look like this: 例如,查询的结尾可能如下所示:
WHERE BatchID in @BatchIdList or BatchID = @BatchIdTextbox
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.