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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppressing a Subreport

Status
Not open for further replies.

TEM3

Technical User
Dec 6, 2004
324
US
I am adding a subreport that will print a list if there are any records found. But, if there is nothing to print I would like the subreport to complete suppress. Is there a way to do that?

In CR 8.5 I am passing the subreport an Oracle table field, {Lab Case}. The subreport will list items with "Open Assignments", if any. If no open assignments are found, I do not want the subreport to do anything. Or it could just print "No Open Assignments".

BTW, I am attempting to pass the table string value from the parent report to a parameter field in the subreport. It looks like it can be done, but I have not been able to test it yet, as I am awaiting a table to be populated before I can test the report. Are there any "gotcha's" in passing a table value to a parameter in a subreport??
 
One way is

Edit the subreport.
Click on File->Report Options and click on Suppress Printing if no records


 
In the subreport, create a section that says "No Open Assignments", in the report footer.
Right-click on the section and choose Format Section. Then choose the formula icon (x+2 and a pencil) for suppression.
Test not isnull({your.field})
The section will appear when there were no records and otherwise be suppressed.

That's assuming you want to show explicitly that nothing was found. If you'd rather have the subreport in its own section and suppress that section, it is harder. In Crystal 8.5, the subreport is evaluated after the rest of the section, and after the decision that the section can be printed. They apparently fixed this in Crystal 9. For Crystal 8.5, you can get a work-round:
a) Copy the subreport
b) Place the subreport in some higher section, and make it as small as possible.
c) Use Shared Variables to pass back a value, that will indicate whether or not the subreport should be suppressed.
d) Use this returned value to determine whether or not to suppress the main copy of the subreport.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top