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

Pass value from main to subreport


jkeri

Recommended Posts

I have  report that contains a subreport. Each one has its own data set/SQL query.

The sql for my main report has two record types., 'ACCOUNT', and 'DTL'.   there is one  record for each 'ACCOUNT and multiple records for 'MAIN'.

What I want to do is for each 'ACCOUNT' record to execute the sub report query.

I need to pass the ACCOUNT.account_number to the subreport account_number query.

How can i do this? 

 

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

So in the subreport you need to create a parameter that is going to hold the value passed over from the main account. 
So if Account filed in main is integer, then create corresponding parameter. Let say AccountSubRpt. 
 

In main report select sub report, then in property tab, select Subreport tab, then there will be a "Edit Parameter" button, use that. 
So in parameter name type in AccountSubRpt. and then in the parameter Expression select your Account field. 
So this creates mapping link between the main and sub. This will pass over the parameter. 

You need to do a couple of other things. 
1) Do not add the sub report in the detialed band. its going to duplicate the report subreport mutiple times. Rather create a dummy group, leaving the expression for the group blank, then you can add the sub report in the dummygroupheader section. 
2) You need to add $P{AccountSubRpt} to your sub report sql query. 

That sohuld be it. 

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...