use of local variable and global variable in crystal reports
55,791
Solution 1
local variable: as the name says it is local to the formula created... it can't be used outside the formula declared.
Use: if you want to use the same name for a variable across many formulas then it should be used.
Global Variable: it can be used out side the scope of the formula created.
use: during calculations there will be use to reset the variable value to 0 anywhere in the report then this should be used.
Along with this there is one more variable that is `Shared` it also acts as a global variable
use: it is also used in resetting the value and also pass values between main report and sub report and viceversa
Edit:*******************
E.g;
creating formula count
Global numbervar a;
a:=a+1;
a
Now I want to reset the value to 0 on change of every group then I use the below formula in group header as below.
Global Numbervar a;
a:=0
Solution 2
local
- current function or formula fieldglobal
- current report (excluding its sub-reports)shared
- current report and its sub-reports
Author by
vissubabu
Updated on April 27, 2020Comments
-
vissubabu about 4 years
Hello all I am new to crystal reports. I just want to know what is a
local
and aglobal
variable. Please suggest what is the difference between local and global variables. -
vissubabu about 10 yearsHi Siva can you please explain use of global variable with an example
-
Siva about 10 yearsuse in my answer itself is an example... what is your exact requirement
-
vissubabu about 10 yearsHi Siva I Just want to know the difference.Please explain this sentence clearly.**it can be used out side the scope of the formula created**
-
Siva about 10 yearsit is like if you create a variable
a
with global access then you can't create the same variablea
in any other formula in a report. Report carries the a reference on whole report for formula see my edit answer.