Suppress Main Report Details if Sub-report blank

Printed From: Crystal Reports Book — Forum Name: Technical Questions

I have a report that has 1 sub-report. I'm looking for a way to suppress the main report details section when the sub-report is blank.

Edited by belfane - 19 Apr 2016 at 10:42am
you have to run the the sub report in the main report header, pass a shared variable back that defines if the sub report is blank (E.g. a record count) making sure to use default values for nulls.
return the shared variable back to the main report in header b.
that value is now available to be used in the rest of the report as a suppression criteria.
if you need to display the sub report in another location you will have to run it twice.
If/when you have the time, would you please elaborate step by step?

I'll try to describe the report here. The main report consists of several data fields, nothing else. The sub-report has one formula, shown below, nothing else. The formula works as expected. When the formula shows no data, I want the main report details section to be blank as well.

if isnull ({data.fruit}) then "None" else ""
Do you know how to create shared variables and pass those to/from sub reports to main reports?
I have the sub-report part of this figured out, still could use some help with the main report.

whileprintingrecords;
shared stringvar blank :=if isnull ({data.fruit}) then "None" else ""

Edited by belfane - 20 Apr 2016 at 8:52am
take a look at these two threads
there are a ton of posts on shared variables and sub reports.
http://crystalreportsbook.com/forum/forum_posts.asp?TID=17870
This goes in to detail on sub reports and shared variables, maybe more than you need.

This explains more why I suggested the order I did
http://crystalreportsbook.com/forum/forum_posts.asp?TID=18293

Let me know if you need more help or maybe someone else can post the sample shared variable code to more directly assist :)