Skip to Content
avatar image
Former Member

Pass list of values from Sub report to Main?

I'm probably making this more complicated than it needs to be:

I have a main report comprised of multiple subreports.

My main report passes a job number to my sub reports.

My subreports each compile a list and a total for that customer (subreport 1 totals equipment, subreport 2 subtotals labor, subreport 3 subtotals materials, etc). The subreports were created by taking every invoice item and filtering it down to the customer and type.

My main report takes those subtotaled values and displays them with other information and calculations.

Now I need a new report that lists every customer and those subtotals for every customer.

Is there any way to do this with my existing report and subreports?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Nov 30, 2017 at 09:37 PM

    You can have another subreport in your report footer and pass all collected values in multiple Arrays

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 04, 2017 at 11:22 PM

    You would create Global variables and use those. I might do it something like this:

    1. In the main report, group on customer.
    2. Suppress the details section.
    3. In the customer group header section, put a formula that will initialize the global variables to 0 (since these are subtotals). If you don't do this, you may end up with numbers from the previous customer.
    4. In the first customer group footer section, put each of your subreports. The subreport should calculate the subtotal in the report header or footer and not contain any other data. The formula for this will look something like:
      Global NumberVar subtotal;
      subtotal := Sum({MyTable.NumberField})
    5. Suppress all subreport sections that are not in use.
    6. In main report, put all of these subreports in the same section and make them as small as possible. Set the "y" position for each to 0. Make the section as small as possible.
    7. In a second customer footer section in the main report, put your data. Each subtotal will be a formula in this format:
      Global NumberVar subtotal
    8. The subtotal variable for each subreport will have to have a different name - otherwise on subreport's data will overwrite another's.

    Note where I did and did not use the semi-colons in the formulas above. This is important for getting things to appear correctly.

    Also, this report will NOT export cleanly to Excel! This is a limitation of the Excel configuration library that Crystal uses, which will does not handle subreports cleanly.


    Add comment
    10|10000 characters needed characters exceeded