Symptom
How to create a Sub report based on the Main report filtered data.
Reproducing the Issue
1. Create a Crystal Report using Xtreme Sample Database and insert Customer table.
2.Create a subreport in a main report.
3.Try to get the data in subreport ,related to the filtered data in main report.
Resolution
1. Create a Crystal Report using Xtreme Sample Database and insert Customer table.
2. Create three formulas :
Reset: WhilePrintingRecords;
stringVar i;
i:="0";
Evaluate: WhilePrintingRecords;
stringVar i;
i:=i+","+totext({Customer.Customer ID});
Display: WhilePrintingRecords;
stringVar i;
3. Place the Reset Formula in Report Header Section; Evaluate Formula in Detail Section and Display Formula in Report Footer Section.
4. In Record Selection of main report write a formula,
{Customer.Country} like [ "Egypt",USA","Austria"]
5. Create a Subreport using a command,
Select * from customer where [customer.customer id] in ({?Para})
Note: {?Para} is a parameter with string data type created at command level.
6. Right Click on Subreport and select "Change Sub report links".
7. Select the @Display formula and link the field with the Parameter field that is "{?Para}".
8. Now the Subreport gets the data related to the filtered data in main report.
Keywords
KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To