Skip to Content
0

Crystal Reports: How to restrict records in main report if a subreport contains a specific value

Nov 29, 2017 at 08:17 PM

35

avatar image
Former Member

My main report groups records by invoice number. Each invoice number has multiple records, each of which has a unique billing id, and which also has a billing status. (The two options for billing statuses are Pending and Paid.)

I have sorted the records so the highest billing id (i.e. the most recent) is at top, and then I put that in my group header, so that only the most recent record appears. (I have suppressed the details section so the only thing visible in the report are the group headers.)

I then created a subreport (using the same data source) that only includes records that have a billing status of Paid, and I joined the subreport to the main report via the invoice number. (The subreport is in the group header of the main report.)

I want to set it so that the only invoice numbers that appear in the main report are those that have Paid in their subreport.

Any advice?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Ian Waterman Nov 30, 2017 at 08:54 AM
0

Personally I would remove subreport and use its SQL to create a command.

You can then join main report query to Command using an Inner join on invoice number.

You might have to change Subreport sql slightly to bring back a unique list of Invoices

Ian

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks Ian...I agree that modifying my SQL makes most sense. But my SQL skills are pretty primitive, and so I'd prefer to modify the report instead.

0
Ian Waterman Nov 30, 2017 at 02:34 PM
0

Then you will have to reverse report.

Subreport becomes main report and Main becomes sub.

However, that will mean Main report executes multiple times ie once for each Invoice in SR

Ian

Share
10 |10000 characters needed characters left characters exceeded
Dell Stinnett-Christy Dec 04, 2017 at 11:33 PM
0

Or you just link the table with the invoices to your main report and in the Select Expert, set it to select only the Paid invoices. Your existing main report should still work. However, it will only show customers that have paid invoices. There is a way to do this where you'll get all customers, but only paid invoices using SQL. If you'll post the SQL from your main report and the subreport along with the formulas from the Select Expert, I should be able to write the query that you need, and explain how it works.

-Dell

Share
10 |10000 characters needed characters left characters exceeded