Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: suppressing section Post Reply Post New Topic
Author Message
Just
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 18
Quote Just Replybullet Topic: suppressing section
     Posted: 23 Mar 2012 at 2:12am
Hi

I have a section where there are a few subreports and a field.
I would like to suppress the whole section if the subreports are all empty.

Any ideas?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 23 Mar 2012 at 3:27am
that's a tough one...as the subreports have to run first before you can suppress...but you need to suppress typically before.
 
The only thought that comes to mind is to check the supress on blank section.
 
depending on your layout of the subreports, you might place all of them in their own section, perhaps with shared variables.  Suppress the section if blank...so if all the subreports are empty, then CR will suppress the section for you.  Each subreport would also report back the number of lines or a boolean, and you can use that to dynamically suppress the following sections.
 
It's an idea, but without knowing the layout it's about the best that I have, besides the standard one....
 
write a stored proc, in that you can create either a 'super' row, or a dataset of tables (and link them in CR) and you can add flags as to whether or not there is data for the subreports, and so would 'know' ahead of time that the subreports would be displayed or not.
 
HTH
 
 
IP IP Logged
Just
Newbie
Newbie


Joined: 21 Feb 2012
Online Status: Offline
Posts: 18
Quote Just Replybullet Posted: 23 Mar 2012 at 3:38am
Thanks for your hints.

I managed to move all subreports to one section and the field to another and this allowed the subreports section to be suppressed when all blank. It disrupted the look of the report though.

But... it works. As to your second suggestion I don't think I got the idea. Being a newbie I can be excused Smile I hope.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 23 Mar 2012 at 4:07am
a shared variable is a value that can cross the boundaries of each report/subreport.
 
so let's say that we put a line counter in each report, so that in the detail section there a formula like:
global numbervar lineCount;
lineCount := lineCount +1;
""  //hide the line count
 
then in each subreport's report footer you would place a formula like:
shared booleanvar x;
global numbervar lineCount;
x := (lineCount = 0);
 
"" //again hides the display...so your report will be blank
 
each subreport would have different name so maybe x1, x2, x3 etc
 
then in the main report, in the section that the fields are in, go back to section expert, and in the suppress x-2 button enter something like:
shared booleanvar x1;
shared booleanvar x2;
shared booleanvar x3;  //these match the values in your subreports
 
x1 and x2 and x3
 
 
 
what did we do? 
first we counted the lines in each subreport
 
next we set the variables to return true if there are no lines in the subreport
 
finally, we compare all the values. 
 
The suppress formula is a bit backwards...it wants to see true to HIDE the values, not to display them.  So, if 1 of the reports displayed something, it would return false, and the suppression formula sees 'false', so it displays the data. If all the subreports are empty, then suppression will see 'true' and hide the additional fields.
 
HTH
IP IP Logged
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