• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1342
  • Last Modified:

Crystal Reports 11 how to use shared variables

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.
0
jsgould
Asked:
jsgould
  • 3
  • 2
1 Solution
 
peter57rCommented:
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;
//etc
""  //output nothing

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

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


//use var1
whileprintingrecords;
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.


0
 
jsgouldAuthor Commented:
Thank you!
0
 
jsgouldAuthor Commented:
Peter57r:
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
0
 
peter57rCommented:
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.
0
 
jsgouldAuthor Commented:
and in the subreports how do I reference them? a formula  for each shared variable or just the name in an expression?
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now