2 Replies Latest reply: Feb 24, 2011 8:10 PM by sharon towler RSS

Pass Data from SubReport to Main Report

Reid Lentz
Currently Being Moderated

I have a main report mainly has some data being printed in the details section of a report.  In the details section I have a subreport in order to retrieve a value from another DB type (one Oracle and another Teradata).  I cannot just link the databases together either which is why I have the subreport.  In the subreport I have it simply printing the description based upon a number which also resides in the main report.  With the subreport in place, the report runs incredibly slow as there are a few thousand (~2-3K) records which effectively need the subreport refreshed each time.  Also, in the report header I need this information to print with the numbers in order for it to make sense.  I basically just want the subreport to run once and send the values over in a variable if possible.  I guess my big problem is not knowing how to properly send data from the subreport to the main report.  I can send in reverse by simply linking the field to the subreport.  Are there any Crystal Report samples where it has a main report with a subreport passing data to it, and NOT the main report passing data to the subreport?

 

Example of how I'm looking to present the data and where it resides:

 

Header->  Product (main report and subreport)        Description (subreport only)

 

What options do I have?  Is this a Shared Variable case?  If so can a detailed response be given as I find it easier to learning visually on my end rather than extended technical write ups.

 

Thank you as always!

  • Re: Pass Data from SubReport to Main Report
    Debi Herbert
    Currently Being Moderated

    Sorry, subreports do not work that way. With it in the detail line, it will refresh for each detail line record. And Yes you can send data from the subreport to the main report, but it must print in the subreport first before it passes to the main report.

     

    Debi

  • Re: Pass Data from SubReport to Main Report
    sharon towler
    Currently Being Moderated

    it depends on what you are trying to pass with a shared variable.

    in the sub report create a shared variable formula

     

    SUB REPORT               

    whileprintingrecords;

    SHARED Numbervar  X := x + ;

     

    MAIN                         

    whileprintingrecords;

    SHARED Numbervar  X;

    X

     

    Shared variables can not be suppressed. I make the font white and the field very small.

    They must be placed below the subreport to retrieve the value.

     

    if you want to pass a total value from the subreport you can place the sub in the header or footer of the repotr, but if you want to pass values based upon a group such as employee salaries, you need the sub to be on the employee id group and link the subreport by that field in order for it to pass the values correctly.

Actions