llasarov
llasarov

Reputation: 2111

Hide subreport on query result

I'm developing an SSRS report containing several sub-reports. The report gets a parameter and uses it to query an object ID which is used as parameter for all sub-reports. The problem ist that in some cases the query returns no object ID (dataset has no data records). In this case I have to hide the sub-reports and show a text message.

I don't know how to set the Show/Hide condition for the sub-reports. I could use a variable for that but I don't know how to set the variable value based on the query result.

Upvotes: 0

Views: 2163

Answers (2)

Igoy
Igoy

Reputation: 2962

On your subreport you can add a Textbox which has text the you'd want to show when no data is returned. The visibility or the hidden property of the textbox should be set as

=iif(Count(Fields!SomeField.Value, "DataSet") > 0, true, false)

Similarly for the subreport put it in a Rectangle and set the visibility or the hidden property as

=iif(Count(Fields!SomeField.Value, "DataSet") > 0, false, true)

Upvotes: 2

llasarov
llasarov

Reputation: 2111

As Jeroen writes, the Visibility value of the SubReport should be set as follows:

=IIF(RowNumber("MyDataSet") = 0, True, False)

Upvotes: 2

Related Questions