Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2838
  • Last Modified:

Suppressing a blank subreport in MicroSoft Reporting Services 2008 using Visual Studio 2008

Hello,

    I have a master report that contains thirteen subreports. I put each subreport into a rectangle to force a page break so that each subreport prints on a separate page. I got the subreport to be not visible of there is no data for the report. By doing this, it's a blank page. I don't want that instead is it possible to not have that blank page displayed? Is there some setting for a subreport to be suppressed if there is no data for the report? If so how do you do that? I'm using MS Reporting Services 2008 in Visual Studio 2008.

      Any feedback would be appreciated.

Thanks for your help,
Ting
0
pensiongenius
Asked:
pensiongenius
  • 3
  • 2
1 Solution
 
PortletPaulCommented:
This is an issue discussed frequently it seems, and there does not seem to be a single best solution (that I could find).

OK, so I've got this figured now. The answer is to place the subreport into a rectangle. Then set the visibility of the rectangle to something like this:

=IIF(First(Fields![SOMEFEILD].Value, "[SOMEDATASET]") IS NOTHING, TRUE, FALSE)

Where [SOMEDATASET] is a dataset populated in the same way as the one populating the subreport. Then if the subreport is empty, then [SOMEDATASET] will also be empty, and more to the point, the field [SOMEFEILD] will be equal to NOTHING.
http://stackoverflow.com/questions/1006343/how-to-supress-empty-subreports-in-ssrs-2008?rq=1

similar approaches are mention in other places I looked at. Note the 'down-side' here is you need to execute the query twice - once to decides if you need to display, and if it is displayed than again to display it.

Other conversations that may give you hints:
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/731e3706-ad2f-4ef5-ac0e-527eadb4e45d
http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/3af7479e-8604-4e1a-af12-8170f0272c9d
http://stackoverflow.com/questions/9093763/hide-empty-subreport-in-ssrs2008-r2

I hope these links provide a solution for you.
0
 
pensiongeniusAuthor Commented:
Hi PorletPaul,

   Thanks for that feedback. Sorry for the delay in responding to your posting.

   The first link that you provided would work if the dataset for my main report and for the subreports were the same.

   It did give me insight to try something based on the Hidden Visibility property of the rectangle. So what I ended up doing was putting each of my subreports into a rectangle. Then in the SQL stored procedure for the master report, I had to declare variables that would be used as record counts for the subreports that I know may or may not have data. Then, I populated fields that I had in a temp table for the subreport record counts with the values of the record count variables. If the record count was zero then I would set the hidden to true for the visibility property of the rectangle and if the record count was not zero then I would set the hidden to false for the visibility property of the rectangle.

Thanks again for your help,
Ting
0
 
pensiongeniusAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for pensiongenius's comment #a39208877

for the following reason:

The reason why I went with mine versus PorletPaul's solution was I had to tweak the solution that he emailed me in the first link in his posting. I do appreciate his help in providing me additional links to research.

Thanks,
ting
0
 
PortletPaulCommented:
>> declare variables that would be used as record counts for the subreports that I know may or may not have data.
good approach, way better than running the sub-report code twice.
0
 
pensiongeniusAuthor Commented:
thanks.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now