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 bkrike 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 Group based on Subreport

Status
Not open for further replies.
Jun 26, 2002
77
US
I would like to know how to suppress a group in the main report if there are no records in the subreport for a group. I have tried using a shared variable and pass a value from the subreport to the main report and then do a record selection based on the result of that value, but it does not work. Any help would be appreciated. Thank you.
 
The thing about subreports is that Crystal does not evaluate them until after it decides to print a section. If it's a detail section within a group, it will also have decided about printing the group before doing anything for the detail line.

There is a standard work-round for detail lines, see thread782-477236 Applying it for groups would be more complex, but you could put a separate subreport in the group head that checks if there is anything to show for the group.

Madawc Williams
East Anglia, Great Britain
 
well one way you can do this is initialize your shared variable in a section before running the subreport.

//@InitializeSubreportFlag
WhilePrintingRecords;
Shared BooleanVar Flag := False;

Now in the detail section of the subreport put a formula

//@UpdateSubreportFlag

WhilePrintingRecords;
Shared BooleanVar Flag;

if not isnull({Table.value} and onFirstRecord then
Flag := True;

Now you can use this update to suppress a section following the section where the subreport is in the main report...you cannot suppress the section containing the subreport...I hope you understand.

in the section following the subreport in the conditional supress you would put

WhilePrintingRecords;
Shared BooleanVar Flag;

not Flag;


hope this helps

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top