Crystal Reports 11 how to use shared variables

Posted on 2009-02-09
Last Modified: 2012-05-06
CR11, main report with 10 sub reports. the first sub report creates several group totals that are needed for calculations in subsequent sub reports. The main report does not need the totals. I'm not sure how to set this up and/or use shared or global variables. No other info or params are passed between reports.
Question by:jsgould
    LVL 77

    Accepted Solution

    You would use a shared variable for each value you want to pass between reports.
    You need to declare the variable in each formula field that uses it and you should initially declare all the variables in a formula field in the main report header.

    shared numbervar var1:=0;
    shared numbervar var2:=0;
    ""  //output nothing

    You create formula fields in your subreports to assign and/or use the values from the

    //assign var1
    shared numbervar var1;
    var1:= {...expression...};

    //use var1
    shared numbervar var1;
    expression involving var1

    Note that the formula field using the assigned value must occur later in the report than the formula field assigning the value.


    Author Closing Comment

    Thank you!

    Author Comment

    not sure if its too late to ask but..
    do I create a formula for each variable in the main or just list them all.
    how do I reference them in the sub report. do I create a formula for each reference if I want it to show on the report
    LVL 77

    Expert Comment

    In the main report you can declare all the variables in one formula field.
    I did 2 variables in my example but you can do as many as necessary.

    Author Comment

    and in the subreports how do I reference them? a formula  for each shared variable or just the name in an expression?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now