Ok, I need help with a simple but important problem. I've built a simple case for understand the problem much better.
I've 2 Excel file:
- Customer data "Customer.xlsx": (ID_Customer, Name, Surname)
-Address data "Address.xlsx": (ID_Address, ID_Customer, Address)
I would built a report that show the customer data and, for each customer, shown the address line (maybe each customer could have 1 or more address).
So, I've created the main report with the fields Name and Surname in the details area. Under the fields I've created a sub-report component and I've also create the sub-report with the wizard process. So now I've the main report and the sub-report.
If I tried to show the data from each report...
- From the main report I can see the list of customer but I cant'see anything from the sub-report component.
- From the sub-report I can see the the list of the addresses of the customer.
So I've realized that maybe I can't see the results of sub-report component in Main Report because I've not explicited the relationship between the two reports and what key create the link. So I ask you to describe me what is the problem, because I'm out of mind actually. Thanks so much.
1 Answer:
Well you should pass the current Field-value $F{ID_Customer} to the SubReport as a so called SubReportParameter with name e.g. "Para_ParentCustomerID" from MainReport at the SubReport-Element.
Inside the SubReport itself you create a Parameter $P{Para_ParentCustomerID} (the same name is important!) and use this within the SubReportQuery. E.g.
SELECT * FROM Adresses WHERE ID_Customer = $P{Para_ParentCustomerID}
That's all.. then the SubReport should filter out just the matching adress(es) from the current MainReport customer.
hth + regards
C-Box