Value of variable in subreport

Hi,

Can I obtain in the main report, the value of a variable calculated in a subreport?

If yes, how can I do that?

Thank's in advance
gids01's picture
27
Joined: Jun 27 2007 - 11:57pm
Last seen: 15 years 11 months ago

15 Answers:

Create a variable for a the 'calculated variable' to be stored into; -> to return to the main report. Remember that the main report must have a variable to store this value as well...

Main Report -> $V{sub_return}
Sub Report -> $V{return_main}
$V{return_main} -> $V{calc_var}

Make sure that the variables match up in your subreport properties...

See the subreports sample...
http://jasperforge.org/sf/wiki/do/viewPage/projects.jasperreports/wiki/S...
codyjasperForge's picture
Joined: Jun 6 2007 - 3:44am
Last seen: 6 years 2 months ago
Ok, thank you very much, but how can I

"Make sure that the variables match up in your subreport properties..." ?

I do not have experience with JasperReport
gids01's picture
27
Joined: Jun 27 2007 - 11:57pm
Last seen: 15 years 11 months ago
First have the main report window active.

Right click on your subreport and choose properties.

Go to 'SubReport (other)' tab

Below is a tab 'Subreport return values'

Make sure that the variable names match each created variable.

$V{sub_return} -> Destination Variable
$V{return_main} -> Subreport Variable

inside the variable definition of $V{return_main} the variable expression should be $V{calc_var}, which has your calculated value inside it.

Once you've done this, you should be able to view the contents of your returned value inside the 'Main' report.(using $V{sub_return})

Hope this helps...
codyjasperForge's picture
Joined: Jun 6 2007 - 3:44am
Last seen: 6 years 2 months ago
I'm very sorry but I can't obtain the value of the variable.

In my subreport, I have 1 variable called "SOLDE" (store the sum) and 1 variable called "SOLDE_RETOUR" (the expression value is $V{SOLDE})

Now in my main report in the properties of the subreport I have that (mainReport.jpg).
gids01's picture
27
Joined: Jun 27 2007 - 11:57pm
Last seen: 15 years 11 months ago
gids01's picture
27
Joined: Jun 27 2007 - 11:57pm
Last seen: 15 years 11 months ago
size=290]
gids01's picture
27
Joined: Jun 27 2007 - 11:57pm
Last seen: 15 years 11 months ago
and in the main report

size=379]
gids01's picture
27
Joined: Jun 27 2007 - 11:57pm
Last seen: 15 years 11 months ago
size=291]
gids01's picture
27
Joined: Jun 27 2007 - 11:57pm
Last seen: 15 years 11 months ago
In the _SOLDECOURANT variable expression, you should have the subreport return variable -> SOLDE_RETOUR

Does this make a difference?
codyjasperForge's picture
Joined: Jun 6 2007 - 3:44am
Last seen: 6 years 2 months ago
If I do that :
size=289]

I have an error : Variable not found : SOLDE_RETOUR
gids01's picture
27
Joined: Jun 27 2007 - 11:57pm
Last seen: 15 years 11 months ago
I am sorry, is there any way that I may see your .jrxml?

This would be very helpful to me...
codyjasperForge's picture
Joined: Jun 6 2007 - 3:44am
Last seen: 6 years 2 months ago
ok, have you an email adresse please ?
gids01's picture
27
Joined: Jun 27 2007 - 11:57pm
Last seen: 15 years 11 months ago
codyjasperForge's picture
Joined: Jun 6 2007 - 3:44am
Last seen: 6 years 2 months ago
Forgive me, I am having problems running iReport...

From what I can see:

Open main report.

Open subreport properties (right click -> subreport(other)

Change your return values to match your variable names.

FOr example:

Change subreport variable from _IMPRIMER_LIBELLE to _SOLDERETOUR

I will have to continue testing...iReport giving problems to me now :pinch:
codyjasperForge's picture
Joined: Jun 6 2007 - 3:44am
Last seen: 6 years 2 months ago
codyjasperForge's picture
Joined: Jun 6 2007 - 3:44am
Last seen: 6 years 2 months ago
Feedback
randomness