Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Suppress Main Report Details if Sub-report blank Post Reply Post New Topic
Author Message
belfane
Newbie
Newbie


Joined: 18 Apr 2013
Online Status: Offline
Posts: 21
Quote belfane Replybullet Topic: Suppress Main Report Details if Sub-report blank
    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.

Edited by belfane - 19 Apr 2016 at 10:42am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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.
IP IP Logged
belfane
Newbie
Newbie


Joined: 18 Apr 2013
Online Status: Offline
Posts: 21
Quote belfane Replybullet 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 ""
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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?
IP IP Logged
belfane
Newbie
Newbie


Joined: 18 Apr 2013
Online Status: Offline
Posts: 21
Quote belfane Replybullet 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 ""

Edited by belfane - 20 Apr 2016 at 8:52am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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 :)
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.