Skip to Content

CR2011: Shared Variables

Hi everybody

I often use shared variables in Crystal Reports 2011, and never had any problems.

This time, I got stuck ... don't know why.

I have a Main report and 2 subreports S1, and S2

I want to pass a shared variable from S1 to S2

So, I create the shared variable (SeriousErrors_sv ) in each of Main, S1, and S2.

I copy and paste the formulas so that you see exactly what I typed, and spot my error

In S1:

SeriousErrors_sv

WhilePrintingRecords;

Shared NumberVar SeriousErrors_sv;

SeriousErrors_sv:= {usp_2014_101.Er5_TotalNoOfEr};

--------------------------------------

In S2

WhilePrintingRecords;

Shared NumberVar SeriousErrors_sv;

-------------------------------------------------

In Main:

SeriousErrors_sv

WhilePrintingRecords;

Shared NumberVar SeriousErrors_sv;

------------

I have placed each shared variable in the respective report.

S1 ---> Reads 9 (Correct)

S2 ---->Reads 0 (Bad)

Main ----> Reads 0 (Bad)

----------

It seems that S1 is not passing the SV to Main.

What could have gone wrong?

Thanks

Leon Lai

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Sep 17, 2014 at 11:22 AM

    The main report formula must be in a section below the section where S1 was placed (NOT in the same section!).  S2 can be in the same section of the main report formula or in a section below that section.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Jamie Wiseman

      Thanks a lot for your reply.

      I did not reply earlier because I had already found an alternative solution to my problem, and did not visit the forum until now.

      I am keeping good note of your suggestion. I may need it someday.

      Best Regards,

      Leon Lai

  • Sep 17, 2014 at 11:23 AM

    Hi Leon,

    The Subreport S2 and the formula on the Main report should be in a section below the section that holds Subreport S1.

    -Abhilash

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 17, 2014 at 11:24 AM

    Hi,

    It depends on where you have placed your sub report1.

    I mean, the value of shared variable declared in sub report1 will not be available in the main report in a section above where you have placed your sub report1.

    If you need that, you may have to place the formula with declaration of shared variable in report header of main report.

    Thanks,

    Raghavendra

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 17, 2014 at 11:32 AM

    The formula used to show the shared variable value in main report should be placed below the section where S1 is executing, while same goes for the physical placement of S2 in the main report.

    -Prathamesh

    Add comment
    10|10000 characters needed characters exceeded