How to get parameter to subreport

0

Hi all,

 

I am desperate here. I am working in Studio 7.1. I have set up a parameter called Program_ID in the main report with a default value STRINGvalue of 'education' that I want to use as part of a WHERE clause in the subreport. I then added a new subreport with the following with use same report connection as main and add the following simple query: 

 

SELECT emp_number
FROM "emp_tbl" 
WHERE PROGRAM_ID = $P{Program_ID}

I added a parameter Program_ID to the subquery. I returned back to the main report and clicked on the subreport, edit parameters button, and set the expression to $P{Program_ID}. When I return to the subreport, it turn up zero results. If I hardcode the program_id as 'education' instead of $P{Program_ID}, I get back the full results that I am looking for.

I have tried everything I can thing of and would really appreciate any help one of you can give me.

white_falcon02's picture
Joined: Apr 1 2017 - 11:59am
Last seen: 7 months 3 days ago

Hi Andy,

It is not for prompting. I have never explored working with xml/xpath or really know where to begin.

white_falcon02 - 11 months 7 hours ago

2 Answers:

0

It is important the wiring of the parameter/s between main and subreport is correct and this includes case sensitivity. 

Here is an example for a department main report with employee sub report using just one common parameter, DEPT_ID:

Main report 

Query :
select * from department where department_id=$P{DEPT_ID}

parameter defined:
DEPT_ID (Is For Prompting = true)

Subreport tab:

Expression = "employeesub1.jasper"
Connection Expression = $P{REPORT_CONNECTION}

Edit Parameters button
Name = DEPT_ID
Expression=$P{DEPT_ID}


Sub report (employeesub1.jrxml)

Query:
select * from employee where department_id=$P{DEPT_ID}

parameter defined:
DEPT_ID

I attached the jrxml files as well. Good luck.

Attachments: 
AttachmentSize
Package icon examplesubreport.zip2.26 KB
vchiem's picture
6990
Joined: May 1 2017 - 5:33pm
Last seen: 1 day 18 hours ago
0

@vchiem

How would this work 1. using XML/XPath and 2. If the parameter is NOT for Prompting ?

andycolman's picture
Joined: Jul 6 2018 - 2:50pm
Last seen: 7 months 2 weeks ago
Feedback