return a variable from one subReport to another subReport in Jaspersoft Ireport - ireport

I have a main Report in jaspersoft. Inside the main Report I have used two SubReports. Inside one of the subreport i have a variable Total Cash. I have to use this variable Total Cash in my next subReport. Is it possible to pass a variable from one SubReport to another SubReport. If not then how can i pass the variable from the SubReport to the main Report.
Thanks.

You can get a return value from a sub-report to the main-report using the returnValue element. The following code sets the $V{result} value in the main-report to the value of $V{total} in the sub-report. This is much more obvious in iReport instead of jrxml code.
Take a look at Subreports for more information.
<subreport isUsingCache="true">
<reportElement x="18" y="11" width="189" height="77" key="subreport-1" />
<connectionExpression>
<![CDATA[$P{REPORT_CONNECTION}]]>
</connectionExpression>
<returnValue subreportVariable="total" toVariable="result" />
<subreportExpression class="java.lang.String">
<![CDATA["C:/Program Files/JasperSoft/iReport-3.0.0/compile/Untitled_report_2.jasper"]]>
</subreportExpression>
</subreport>

Absolutely you can :
Just set the return value from the first subreport to your desired variable in main report, then on your second subreport pass parameter with the value of your previous variable. But you will get null value if you placed second subreport in a same details band with the first subreport, then try to add more details band and place your second subreport here.

Related

SSRS passing parameters to a second tablix in the same report making it visible

I need to pass parameters to a second tablix in the same report from clicking in a cell on the first tablix a bit like adding an action to a text box that passes parameters to a second report. The second tablix needs to be hidden until the row in the details column on the first tablix is clicked.
I'm not sure if this can be achieved?
Have just tried SQL Dan's method and that also has worked for me. Pointing the Action of a cell in the details row of tablix in the parent report back to the parent report and including the extra parameters (Hidden) that the subreport requires.
On first running the report I get an error for the subreport " One or more parameters were not specified for the subreport 'Report Name', located at: / Report Name', but that's fine as on first running the report I wanted the subreport hidden so expression in visibility of subreport for show / hide which is based on the parameters that are not passed on first running the report. So when first running the report you don't get the error as the subreport is not visible until the on click event.
When clicking on a row in the main tablix the report reloads as in action points back on itself and the parameters are passed for the subreport.

Show tablix total outside of table

I have a weekly report which totals anywhere from 200 - 1000 rows of data. For my accounting people, the total is the only value of import as they simply use it for accrual purposes. I would like to either have the total appear at the top of the report or in a separate text box indicating this is the total for the report. Does anyone have a good idea on how to accomplish this?
If I understand correctly you need to get the result of some aggregate function on a tablix shown in a textbox outside the tablix.
That can be achieved by placing a textbox anywhere on the report, and in the expression for that textbox add a reference to the dataset you need to aggregate, e.g.:
=Sum(Fields!SomeValue.Value, "myDataSet")
Where SomeValue is the name of the field you need to aggregate, and myDataSet is the name of the DataSet that fieldis in.
Your question has already been answered by the other answer. Just as an alternative, you could try one more thing.
On the "details" row group(which appears by default), right click and choose "Add Total".
This will appear in a separate text box outside the report.

Crystal for VS2013- main report not passing param to linked subreport

I have a report, and a linked subreport. The subreport is linked on a field on the main report.
A field in the main report should link to the subreport at run-time, but when I run it, keep on getting the prompt "Enter parameter values".
The field in the main report is linked to the subreport using the automatic parameter name in the subreport, and have the "select data in the subreport based on field" checked, and the corresponding field in the subreport (shown in the attachment).
I am using Crystal for VS 2013.
This is a winform application.
What am I missing?
I seemed to have the same issue under the same parameters you described. Moreover, while debugging, the winforms app would throw a COM exception. Context switching between VS and the report would reveal the prompt for the subreport parameters (which should have been linked).
An hour of exploring and trial-and-error later, here is how I managed to resolve the issue in VS2013:
On your main report, right-click the subreport and select 'Change Subreport Links...'
Ensure that you have the correct subreport selected, the move across any missing parameters from the 'Available fields' box
For each item you move across, ensure that you have the correct subreport parameter selected in the 'Subreport parameters field to use' drop down list. For parameters, this will generally take the form '?#ParamName'
That got the report working for me again. I hope you have some luck with it!

Can you get value from SubReport?

I have a SubReport with a textbox, I would like to read the value of this textbox and then put it in the main report for each data row.
My SubReport is in a data column.
If you are using Visual Studio, you should be able to drag and drop the sub report object into the text box and configure it from there. But make sure that if the sub report expects parameters, you send the required parameters.

How to read control / variable value in rdlc?

I want to display the value from dropdown on aspx page to the rdlc header.
how can i achieve this.
Create a text parameter for your report to accept the value, then add a label to your report header and enter an expression such as =Parameters!TheDropDownText.Value for its value; you'll need to supply the report parameter its value when you run the report, but that's another topic :)

Resources