on 09-17-2014 12:18 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ido,
Thanks for your reply.
I tried your suggestion, but unfortunately it does not work.
In S1, I placed the SV in the Report Header (reads 9 = correct)
In Main, I placed the SV in the Page Header (reads 0 = incorrect)
Then I placed the SV in GH1, and also Page Footer (same error)
Hope this will help to pinpoint my error
Regards
Leon Lai
Hi Leon,
Make sure you do not have another formula inside the Subreport S1 that resets the shared variable to zero.
Also make sure you do not have another formula on the Main Report, somewhere on the Page Header or Report header that resets this variable to zero.
There's no other reason the shared variable shouldn't work otherwise.
-Abhilash
Hi Abhilash
No, I have not reset the SV.
I tried putting a fixed value (= 1) in S1 instead of a field value
The 1 is not passed to the Main Report
I also tried to pass a SV from Main to S1
It works without problems.
So, I can pass a SV from Main to S1,
but not from S1 to Main.
I'll continue fighting the problem...
And thanks to all who have replied similarly. I did not expect to get so many replies
Best Regards
Leon
Hi Abhilash
There is something which is worrying me...
My subreport is an ON-DEMAND subreport
When I run my report, SV for main gives 0 (even though SV in S1 gives 😎
I find this very logical!
S1 has not yet run (because I have not yet clicked on the S1 hyperlink).
So, this is not the way to pass a SV from S1 to Main???
Could you reconsider my question in the light of this observation?
Best Regards
Leon Lai
hi Leon,
your other option is to format the subreports in such a way so that they look and act like on demand subreports. have a look at the attached report...extract the contents and change the .txt extension to .rpt.
notes:
1) as you saw the subreport has to run in order to pass variables
2) in this example, the subreports are not On Demand subreports
3) in the Format Subreport > Common tab, Can Grow is not checked
4) the subreport has a fake url in the subreport report header A
5) subreport report header A is suppressed when opened
-jamie
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.