| Author |
Message |
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|

Topic: shared variables subreport to subreport Posted: 19 Nov 2013 at 8:53am |
|
Hi,
is it possible to share a variable between 2 subreports as well as the main report?
If someone knows the answer, would you please reply in detail how to do this?
Thanks so much!
|
IP Logged |
|
|
|
Sastry
Moderator
Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
|

Posted: 19 Nov 2013 at 7:14pm |
Hi
Yes, that is possible. If we can take care of variable flow that will pass values from sub to main reports.
Example :
1st Sub report : define shared variable and place the variable in your sub report and place this sub report on report header.
In the Main report you can call this shared variable value in any of your sections which are after report header.
2nd Sub report : you can also call the same variable into this sub report. this sub report should be inserted in your main report after your main reort process shared variable.
Flow would be :
1-- 1st sub report
2-- Main Report
3-- 2nd sub report
|
|
Thanks,
Sastry
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
|

Posted: 20 Nov 2013 at 4:48am |
|
Hmmm...I would have thought that if the shared variable is only needed in the subreports, that you could call straight across and not have to involve the main report.
Usually, you want to display the shared variable in the main report, or reinitialize it and the main report is the place to do that, but you would think that it isn't necessary.
Now I have never used a shared variable between 2 subreports...so I could be completely wrong. I state the above as CR help says that a shared variable is scoped to encompass the main report as well as any subreports. So...it should be able to exist without the main report ever knowing about it
Just my thoughts, and I've been wrong before.
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|

Posted: 20 Nov 2013 at 8:44am |
|
I do not believe it will be an issue provided you put each sub-report in their own section. I had several sub-reports that performed similar tasks and I had used the same name for some of the shared variables. When I got some odd results, I realized that the shared variable from one sub-report was 'corrupting' the shared variable in another sub-report.
|
IP Logged |
|
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|

Posted: 21 Nov 2013 at 6:03am |
|
Hi, thanks for your reply. I do not know too much about shared variables. I tried to do it in my report but did not work. would you be able to give me an example of the formulas ?
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
|

Posted: 21 Nov 2013 at 8:19am |
|
shared numbervar x;
if {table.field} = something then
x:= {table.field2};
the important part is the declaration statement:
shared numbervar x;
assignment is := where as equals is =
usually the formulas come in sets of 3, reset, increment, display. The example is like an increment.
reset would be the same but
x:=0
and display is just:
shared numbervar x;
there are different vars...you can look in CR help to find the rest...like stringvar, datetimevar, booleanvar, etc.
HTH
|
IP Logged |
|
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|

Posted: 22 Nov 2013 at 10:06am |
|
I made a mistake when I said I wanted to pass the data to the main report. I just need to pass it from one subreport to the other. I am still having a problem with this.
|
IP Logged |
|
Sastry
Moderator
Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
|

Posted: 23 Nov 2013 at 6:32pm |
Hi You can very well pass shared variable value from one sub report to another without passing it to main report. Ex : create this fromula in your first sub report, importent thing is you have to place this formula on report canvas otherwise it will not get processed. whileprintingrecords; Shared Numbervar x:=200; Create the following in your second sub report to check whether that value will be passed or not. whileprintingrecords; Shared Numbervar x;
|
|
Thanks,
Sastry
|
IP Logged |
|
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|

Posted: 25 Nov 2013 at 7:58am |
|
Thank you. What should I replace the 200 with ?
|
IP Logged |
|
Sastry
Moderator
Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
|

Posted: 25 Nov 2013 at 9:18pm |
Hi Whatever value you want to bring from sub report to another, pass that value to 'x' variable.
|
|
Thanks,
Sastry
|
IP Logged |
|
|
|