Monday, March 12, 2012

How to suppress the subreport when there is no data in it?

Since there is no way to pass value from subreport to the main report, how to suppress the subreport when it is blank?

Thanks.

The subreport reportitem (in the main report) has a NoRows property. If all the dataset queries inside the subreport return 0 zero rows and the NoRows property is set explicitly, it will replace the contents of the subreport with the NoRows message (which could be a blank string).

-- Robert

|||

OK, so how do you hide the row that contains the subreport is the subreport is blank? Is there an expression you can enter into the NoRows property?

Thanks

|||

Ditto -- What is the expression to suppress the table row that contains the subreport when the subreport has no data?

Thanks,

Pete

|||

Can you explain your scenario in more detail please?

The closest you can get right now is to have the subreport queries in the main report and then determine the visibility of the table row in the main report based on the CountRows("DataSetName") aggregation result.

-- Robert

|||

Hi Robert:

Basically I'm testing SSRS 2005 compared to our current report design/production in Crystal Reports XI. One of the features of CR that we use extensively is subreports. When a particular section of a CR report does not have relevant subreport data to display, we dynamically hide the main report section that hosts the subreport so as not to display any info that is in the same main report section but not in the subreport.

I've found a thread that appears similar in nature to my situation: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=423404&SiteID=1

Most discussions I've reviewed about dynamically hiding subreports in SSRS resolve to the conclusion that if a subreport does not have data, then the subreport hides itself which should be "good enough". This feature, while useful sometimes, won't help my situation in which other data from the Main report would also need to hide.

I've attempted to nest regions, instead of using subreports, (e.g., a List region that nests a Table region) whereby the List region refers to dataset1 while the Table region refers to dataset2, but I am unable to display the report successfully. I usually receive an error that I am attempting to display an aggregate within a nested data region.

By the way, the link I mention above has a comment that "in order to use a nested data region you have to (unfortunately) use the same dataset as the parent data region, which means that you will have to combine the datasets for the report and subreport into one dataset/query. If you NEED to use a separate dataset you will have to use a subreport." Is this a correct statement?

So far, the solution I've crafted requires me to alter the sql stored proc to support both the main report and subreport, effectively forcing a one-to-one relationship between the main report and subreport. Ideally, I'd like to construct a report where the main report can have linking keys not always found in the subreport (i.e., similar to a sql outer join), and then have the main report dynamically hide/show the hosting data region or table row. Even better would be to avoid using subreports, and figure out how to have a single report use data regions with different datasets such that the same effect is achieved as if I had used subreports. (This last point assumes better query/reporting performace can be achieved.)

Lastly, I've attemped to filter results of one data region based on data in another data region without success. Again, usually I've attempted this by nesting data regions unsuccessfully -- possibly because each data region refers to different datasets?

Thanks,

Pete

|||

Hi Andrea,

Did you find the solution to hide the row?

i have same problem..

Thanks alot..

|||No, I did not. Instead I have 'No data available' displayed when there is no data appearing from the subreport.

No comments:

Post a Comment