Monday, March 19, 2012

Displaying sub report even when it has no data

Hi,

I have a main report with a sub report in it. Sub Report contains 1 table and some labels. I am passing 1 parameter from the main report to sub report on the basis of which sub report is generated with in the main report. In case if there comes some records in the sub report than the table as well as the other labels of the sub report are coming properly. But if no records are there in the sub report than it doesn't display the complete sub report i.e. no table and no labels which are with in the sub report. I want to make sure that labels should come even if there is no data in the sub report.

I had this same problem. The solution I came up with was to modify my stored procedure to always returnsome value.
SELECT @.Count =Count(*)FROM TableWHERE parameter1 = @.parameter1AND parameter2 = @.parameter2IF @.Count > 0BEGINSELECT Field1, Field2, Field3,DummyValue = -1FROM TableWHERE parameter1 = @.parameter1AND parameter2 = @.parameter2ORDER BY Field1DESC, Field2DESC, Field3ENDELSEBEGINSELECT DummyValue = @.CountEND
I don't know if this is best solution, but it definitely works. Hope this helps.

No comments:

Post a Comment