How to pass the data from subreport to parent report?

Posted by: kyawym on 4 August 2017, 3:01 pm EST

  • Posted 4 August 2017, 3:01 pm EST

    <FONT face=Verdana size=2>Hi,</FONT>


    <FONT face=Verdana size=2>I have one report with two sub-reports.</FONT>


    <FONT face=Verdana size=2>Each sub-reports have some calculated fields at run-time.</FONT>


    <FONT face=Verdana size=2>I want to show the total fields in main report by adding the two fields from two sub-reports.</FONT>


    <FONT face=Verdana size=2>Is there any way to pass the data from sub-report to parent report?</FONT>


    <FONT face=Verdana size=2>thanks in advance.</FONT>


    <FONT face=Verdana size=2>Regards,</FONT>


    <FONT face=Verdana size=2>Kyaw</FONT>


    <FONT face=Verdana size=2></FONT> 


    <FONT face=Verdana size=2></FONT> 

  • Replied 4 August 2017, 3:01 pm EST

    <FONT face=Verdana size=2>Is the ParentReport property Read-Only or Read-Write?</FONT>


    <FONT face=Verdana size=2>The Help file say that property is read-only. Is it correct?</FONT>


    <FONT face=Verdana size=2>FYI : I use Active Report 2.0 .</FONT>

  • Replied 4 August 2017, 3:01 pm EST

    It is a read-only meaning you can not set it to a report but you can use it to change values in the parent report. Have you tried it to change a value of a public variable or a text box on the parent report?
  • Replied 4 August 2017, 3:01 pm EST

    <FONT face=Verdana size=2>Hi Ali,</FONT>


    <FONT face=Verdana size=2>When I use that property in subreport, I got that following error.</FONT>


    <FONT face=Verdana color=#ff1493 size=2>Err 5000 : Error in processing report
    [ Extended Info : SubReport for control SubCurr failed. Failure due to
    : Source : Report, Event : OnFetchData, Line number: 136
    Description: Object required: 'rpt.ParentReport']</FONT>


    <FONT face=Verdana color=#000000 size=2>Please advise.</FONT>


    <FONT face=Verdana size=2>Thanks a lot.</FONT>


    <FONT face=Verdana size=2></FONT> 


    <FONT face=Verdana size=2>Regards,</FONT>


    <FONT face=Verdana size=2>Kyaw</FONT>


    <FONT face=Verdana color=#ff1493 size=2></FONT> 

  • Replied 4 August 2017, 3:01 pm EST

    Can you please post the code you have in OnFetchData.
  • Replied 4 August 2017, 3:01 pm EST

    You can use the ParentReport property to access to pass values to the parent report. For instance to set a field control on the parent report from the summary field in a subreport:

    Me.ParentReport.txtOrderTotal.Text = txtExtPriceTotal.Text

    txtOrderTotal is a Field control on the parent report and txtExtPriceTotal is a field in the subreport where you summarize the calculated field. Similarly, you can add to the value of a variable in the parent report from each of the two subreports.
  • Replied 4 August 2017, 3:01 pm EST

    <FONT face=Verdana size=2>Hi Ali,</FONT>


    <FONT face=Verdana size=2>I got it. :)</FONT>


    <FONT face=Verdana size=2>I put the subreport in the group, gfCcyCode.</FONT>


    <FONT face=Verdana size=2>My subreport control's name is "SubCurr".</FONT>


    <FONT face=Verdana size=2>In the OnAfterPrint event of gfCcyCode, I put the following code.</FONT>


    <FONT face=Verdana color=#0000ff size=2>rpt.txtTotalInvoice.DataValue = rpt.sections("gfCcyCode").Controls("SubCurr").object.txtTotalInvoice.DataValue</FONT>


    <FONT color=#0000ff><FONT face=Verdana color=#000000 size=2>Anyway, Thanks a lot. :)</FONT></FONT>


    <FONT color=#0000ff><FONT face=Verdana color=#000000 size=2>Regards,</FONT></FONT>


    <FONT color=#0000ff><FONT face=Verdana><FONT size=2><FONT color=#000000>Kyaw</FONT>
    </FONT></FONT>

    </FONT>

    <FONT face=Verdana size=2></FONT> 

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels