Calling a sub-report within Jasper reports is pretty normal. Passing a value (the result of a query) back to the main report is what this blog post is all about.
The first thing is to define a variable in the main report (which is calling the sub-report. This will hold the value “passed back from the sub-report”:
Then in the sub-report, you need to associate the _value _from the sub-report (which is PATCH_TITLE), with PATCH_TITLE2:
This is the variable definition of PATCH_TITLE in the sub-report:
This is the sub-report definition in the main report. The returnValue statement associates PATCH_TITLE2, with PATCH_TITLE:
Finally, when you want to display PATCH_TITLE2.
It is important to define the sub-report in the same band as you want to “physically” display the data in. The “textField” must have an evaluationTime of “Band” set, otherwise you will get null values for PATCH_TITLE2: