locked
Displaying a Shared Variable (populated in a subreport) in the Report Header

    Question

  • Hello,

    I'm trying to display a count of the details from a subreport. To do this, I'm using a Shared variable so that both the report and the subreport can get to it.

    I followed these instructions that got me started:
    http://www.builderau.com.au/strategy/architecture/soa/Crystal-Reports-three-formula-trick-/0,339028264,320279915,00.htm

    Everything seems to be working ok, but I need to display my counter on the main Report Header, as a cover page. When I try to display the shared variable, it shows 0. If I display the variable in the footer, it displays the right number.

    It seems to be working this way because of the order things get processed in Crystal. The header gets rendered before the subreport so at that point the variable is 0. On the other hand, the footer gets rendered after the subreport, so the variable has been populated and it gets displayed correctly.

    I need to have this variable on the Header, as it's information going on a Cover Page. Do you guys know of a workaround?

    Thanks!
    Tuesday, August 25, 2009 9:06 PM

All replies

  • Did you try adding:
    "whilereadingrecords"
    at the top of the formula field?
    • Proposed as answer by Ameer Jafri Saturday, October 31, 2009 6:32 AM
    Wednesday, October 28, 2009 11:20 AM
  • Ameer has given you the answer.
    Crystal does a four pass process on reports before rendering them.
    Beacuse of this any totals get calculated in thier relative position in the document. This is a good thing unless as you describe you want the total on the first page.
    In this instance you need to tell Crystal to stop processing the value after it has read the records and before it starts laying out the report

    whilereadingrecords;

    // rest of formula

    whileprintingrecords;

    // rest of formula


    Look both of these commands up in help and read the topics for more details and examples

    Regards

    Rupert
    the problem is not what you don't know it's what you think you know that's wrong
    • Proposed as answer by Ameer Jafri Saturday, October 31, 2009 6:32 AM
    Thursday, October 29, 2009 4:30 PM