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

pass field to a subreport


ondreia

Recommended Posts

  • Replies 11
  • Created
  • Last Reply

Top Posters In This Topic

Create a subreport parameter (for the sub-report from the main report) called "paramA" and pass it the value you wish by setting the report expression as needed. If the value is in a field try using $F{myField} as the expression, if its a parameter that was passed to the main report, use $P{myParam} etc. etc.

 

Then in the sub-report create a parameter called "paramA" which will receive this parameter.

Link to comment
Share on other sites

Thanks rsilver!!!

 

It's a value in a field.

I create (in my report) a parameter and i put in the default value expression: $F{mfield}.

 

Then Im my subreport I create a parameter with the same name but it didn´t work :(

 

Am i doing anything wrong??

Link to comment
Share on other sites

  • 3 weeks later...

Hi, can you please write your solution..i am experiencing the same problem, i have a parameter in my main report and would like to use it in the subreport too. So, in the subreport properties window, i have added all the parameters of the main report to the subreport. Then, in the subreport, i have created a parameter with the same name and properties and thought this paramter wold know take the passed value, but it is not! The report query of the subreport encounters an error as I try to use the parameter in the query and as the parameters value is null. So, if you could please write, how you have solved your problem, it would be very helpful for me..

 

thx in advance,

blckn size=371]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/sub.JPG

Link to comment
Share on other sites

how did u do that? I thought you can not assign the value of a field to a parameter, because the parameters are initialized before the fields. This is how we can use the parameters in queries. So how did u pass to field to a subreport?

 

I need to use the field value in my subreports and could not find any solulcktion. Tried the solution above but it did not work..so now you have written that you found something and I kindly ask you to share it with us...

Did you assigned the value of the field to a variable? If yes, how did you pass the variable to the subreport? Because using iReport only parameters can be passed tı subreports..

 

I really would appreciate if you could share your solution with us..

 

thx in advance

blckn

Link to comment
Share on other sites

  • 7 years later...

Using iReport 5.2:

In the master report, click on the subreport, and find Parameters in the Properties box. Click on the ... button to open up the Parameters dialog.

Click Add and type in a name for the parameter. You will see a button on the right. Click it and you will see all the parameters, fields, and expressions from the master report. Select the field you want to use. Click OK twice to save all this.

In the subreport, create a parameter with the same name as  the one you just entered in the master report.  Now use it like any other parameter,

That's all there is to it.

 

Link to comment
Share on other sites

  • 2 months later...
  • 1 year later...
  • 1 year later...

I'm trying to do exactly this now with jaspersoft studio 6.2 I have created the parameter based on a field from the main report. The report runs, when I display the data on the main report it prints but but is always blank on the table.

 

I've spent literally hours on this reading just about every thread, but I couldn't find any clear direction that is current.

 

Maybe its my data source settings (not mentioned here)? I've tried all sorts of variations from other threads, but always the textfield displaying the parameter in the table is empty.

 

Is it not possible to pass a FIELD from main to a subreport or table? I've seen conflicting statements of differing age so I can't really tell what's true currently.

 

I know I can just perform the query in the subreport. But I have a very efficient query in main so I see no reason to not just reuse the data. Why hit the db again when I've already pulled all the data I need.

 

Thanks!

 

 

UPDATE

For anyone else that stumbles across this post, here's how I resolved it. Don't know why it didn't occur to me sooner, but you don't have to use the table component for this. You can simply place textfields and static textfields arranged to LOOK like a table in the main report using the main fields. It will still export to docx as a table that can be manipulated in word like any other table (that was one of the business requirements for the report I was working on).

 

I also had to mesh a table with data from the main report together with several rows from a subquery. So I used the same technique for the main report data, then added a table component with just the detail rows and physically placed it under the static text 'table'. It also exported to docx properly. jaspersoft studio FTW!

Link to comment
Share on other sites

  • 6 years later...

best way, thank you

 

Using iReport 7.2:

In the master report, click on the subreport, and find Parameters in the Properties box. Click on the ... button to open up the Parameters dialog.

Click Add and type in a name for the parameter. You will see a button on the right. Click it and you will see all the parameters, fields, and expressions from the master report. Select the field you want to use. Click OK twice to save all this.

In the subreport, create a parameter with the same name as  the one you just entered in the master report.  Now use it like any other parameter,

That's all there is to 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...