Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress main report footer if subreport (in main footer) is empty

Status
Not open for further replies.

gk17

Technical User
Sep 6, 2013
86
US
I have a report that has a group header and fields in the details section. There is also a sub-report in the footer.

Currently, it's returning all the data for those fields. I want to suppress the details in the main report if the subreport has no records. I tried searching online on how to do this and think I might need a shared variable which I'm not too familiar with. The sub-report only has the details section with fields. All other sections are suppressed by default.

I tried using the suppress blank sections already and that doesn't seem to have any effect. I selected that option from the Section Expert from both the main and subreport along with the Format Subreport > Subreport tab.

The next thing I tried was with the shared variable. Maybe I'm not using it correct. I created two formulas:

Formula in subreport footer which is suppressed already
Code:
whileprintingrecords;
shared numbervar showsection;
showsection := 1

Suppression formula in main report for group header, details and group footer where subreport is. Also tried just putting the formula field in those sections and it just returned True/False. Not sure what the pattern is either because some of them are returning False when there is no data in the subreport while others also return False when there is data.
Code:
whileprintingrecords;
shared numbervar showsection;
showsection =0

My report is completely blank aside from my group header if I use the above shared variable in my suppression formula.

Thanks in advance.
 
First off, using just an equals sign becomes a comparison, thus to assign a value to anything you have to use the := combination.

I think you would have to do some sort of if statement in the sub-report. i.e., If isnull{reportedfield} then Showsection = false else Showsection = true (assumes Showsection as boolean datatype).
 
Not yet. I took a look at it but didn't get to test it out yet. Still new to using shared variables or variables in general. Will see if I have some time to try this out next week at work. Thanks.
 
To make that technique work you will have to move the subreport to the Group HEADER.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
EDIT: Deleted prior reply...

I was able to get this working perfectly now. Just wanted to mention the solution that resolved this. I used the method mentioned by the OP here and that worked with some tweaking in the suppression formula to exclude false return values.

Thanks everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top