Print Page | Close Window

Suppress Main Report Details if Sub-report blank

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21938
Printed Date: 28 Apr 2024 at 10:21am


Topic: Suppress Main Report Details if Sub-report blank
Posted By: belfane
Subject: Suppress Main Report Details if Sub-report blank
Date Posted: 19 Apr 2016 at 10:40am
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.



Replies:
Posted By: DBlank
Date Posted: 19 Apr 2016 at 12:19pm
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.


Posted By: belfane
Date Posted: 20 Apr 2016 at 8:01am
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 ""


Posted By: DBlank
Date Posted: 20 Apr 2016 at 8:31am
Do you know how to create shared variables and pass those to/from sub reports to main reports?


Posted By: belfane
Date Posted: 20 Apr 2016 at 8:33am
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 ""


Posted By: DBlank
Date Posted: 20 Apr 2016 at 8:54am
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 :)



Print Page | Close Window