Print Page | Close Window

How to filter a main report based on data in a sub

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22414
Printed Date: 28 Apr 2024 at 7:10pm


Topic: How to filter a main report based on data in a sub
Posted By: NCGOV
Subject: How to filter a main report based on data in a sub
Date Posted: 16 Aug 2017 at 10:52am
I am working on a report that consists of a main and sub report. The main report is grouped by name field. The sub-report is LWMAIN data. Currently I am using a shared variable formula to show the number of offenses a person has. I want to display in the main report only those persons with more than one offense listed in the sub-report.
How can I filter the main report to display only this data? If there is an easier way let me know. The reason I have a sub-report is so that I can work with the data better.


Main report formula -

WhilePrintingRecords;

shared numbervar x;

x;


Sub-Report Formula -

WhilePrintingRecords;

shared numbervar x;

x := 0;

x := Count ({lwchrg.chrgdesc});

x;




Replies:
Posted By: DBlank
Date Posted: 17 Aug 2017 at 5:07am
I would not use the sub report but if you have to you will need to do suppression not selection.
The easiest thing is likely a stored proc or crystal command that would do the grouping and counts in the data source then you can select from that.
If not you can link the incidents to the person in the main report, group on the person and the incident type and do some group summary counts to do group selection.
The sub report gets tricky more resource intensive but is plausible.
Will the above options work rather than the sr?



Print Page | Close Window