Sunday, February 26, 2012

Hiding tables in a report

Hi,

Can anyone help me with the expression I need to use in order to hide a table with no rows? I have put my table inside a rectangle with the idea that I would just hide the rectangle if there weren't any rows but I can't find any examples of what expression I can use to specify the no rows condition.

Thanks!

Debi

Something like for the Hidden property of the rectangle:

=iif(RowCount("NameofDatasetPopulatingTheTabe") > 0, "false", "true")|||

Andy,

Thanks for the posting. RowCount doesn't work for me (unrecognized identifier). That may be because I am using the ReportViewer control in an ASP page and not actually using SQL Server Reporting Services. I probably should have included that in my original posting. Also, if it makes a difference this is a subreport that is using a filter based on a parameter passed from the main report. I'm not sure if that will makes a difference but the datasource will usually have records but a table may not have any rows due to the filter. I want to eliminate the header that gets displayed when there are no rows to show.

Thanks!

Debi

|||

I have made some progress on this. The correct syntax is:

=IIf(CountRows("table1") > 0, false, true)

I added this to the visibility of the table and it does hide the table header if there aren't any rows. The only problem is that it still leaves the white space that would have been occupied by the table header. I had read some tips about creating a rectangle and then moving the table into the rectangle and setting the visibility for the rectangle but I can't get it to work. If I use the same expression I get the following error:

Error 1 The Hidden expression for the rectangle ‘rectangle1’ has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a data set.

It seems that table1 is out of scope in this instance but I can't figure out how the scope should be defined. Any one have any suggestions?

Also, will this even accomplish what I want (eliminating the whitespace)? This rectangle/table is in a subreport if that makes any difference.

Thanks!

Debi

|||You can use the same logic for a rectangle, but your scope parameter needs to be the name of the dataset, not the name of the table.

So if your table uses a dataset like "MyDataSet", then use that instead of "table1". The Rectangle will be aware of that scope.|||

Just thought I would mention that there is also the ability to set a message when a table has no rows. This automatically hides the table and displays your message. Setting the "No Rows" property expression to = "" will also hide the table with no message.

Simone

No comments:

Post a Comment