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!

subreport within a subreport 2

Status
Not open for further replies.

BJD

Technical User
Jun 22, 2001
27
US
I have a report that is used as a subreport (call it report A) . It has one subreport (subreport B). When I insert report A into my main container report, subreport B is not there. The Detail section where I had inserted subreport B is there but empty. Reports A & B are reports that were created separately, then inserted as subreports. Can you have a subreport within a subreport?
 
No - you cannot nest subreports within subreports. See Crystal Reports Online Help - "Subreports" :-(
 
You can't have a subreport, but in some cases you can achieve the same results using what I call a middle-out approach:

Imagine you have a report showing for each
customer all their orders and all the line items.

You can't create it as a Main report for Customer and within that subreport for Orders, and within that subreport another subreport for line items. This is because a subreport cannot conain another subreport.

As a side note, we can obviously use grouping levels and avoid the need for subreports in this case. This is just for demonstration purposes. However, in many cases what seems like a need for a subreport can be removed by better SQL and grouping.

Now assuming we must separate Customers/Orders/Line Items into a main report and subreports, we can still achieve this using what I call a "middle-out" approach:

1. Make the middle layer (Orders) the main report.
2. Make the top layer (Customer) a subreport inserted in the group header of each Order. This subreport will return only one Customer for each order. If needed, you can suppress it (using a shared variable) if the previous order had the same customer.
3. Make the low layer (Line Items) a subreport
in the group footer of the Orders. This subreport would show all line items for a given order.

Cheers,
- Ido ixm7@psu.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top