Passing parameters from main report to subreport in Jasper

user1898250 picture user1898250 · Dec 12, 2012 · Viewed 76.1k times · Source

I have a JasperReport where I am passing the report Date from a Main Report to a sub report. This works fine. I also have another where I am passing the same parameter to a sub report that has multiple SubReports. When I preview it in Ireports all the pages for it appear blank which means the sub-sub reports are being called but the report Date is not being passed as all the sub-sub report SQL are conditioned on the report Date. How can I get the report Date field to the sub sub reports? When I preview the SubReport and type in the report Date all the report dates work all four pages are populated with the correct data.

Answer

Ahmed Salem picture Ahmed Salem · Feb 17, 2013

Follow the steps below to pass parameters into subreports:

  1. Create main report parameter, such as DATE_PARAM.
  2. Open sub report and Create a parameter with the same name and the same type.
  3. Go back to main report
  4. Right-click on sub report, select properties
  5. Choose parameter
  6. Add parameter from main report to sub report with parameter name same parameter name

The parameter is passed from the main report to the subreport.