Jump to content
We've recently updated our Privacy Statement, available here ×

How to get parameter to subreport


white_falcon02
Go to solution Solved by vchiem,

Recommended Posts

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_numberFROM "emp_tbl" WHERE PROGRAM_ID = $P{Program_ID}[/code]

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.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...