Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i use global variables 1

Status
Not open for further replies.

JGSol

Programmer
Jul 14, 2005
2
BO
i need use global variables, but i don`t know where should be create that.
i need asign a value and create many formulas whit that values, and update values for each formula.
for example:
global val1 as integer
global val2 as integer

in formula 1 i need work with two global variables and update that values.

in formual 2 i need work with two global variables after update in formula 1

please help me!!!!

 
Using Crystal syntax, you could create a formula like the following:

numbervar discount := .05;

You could place this formula in the report header and then reference the variable in other formulas, as in:

numbervar discount;
if {table.store} = "A" then discount * 2 else
if {table.store} = "B" then discount * 3 else
discount;

You would place a formula like this in any section below the one in which you have declared the value of the discount. You do not explicitly have to say "global numbervar discount", since global is the default type of variable, and of course you can name your variable something other than "discount", e.g., "x", "myname", etc.

To change the value of "discount" in all formulas that reference it, you would just change the value in the initial formula.

-LB
 
If you go to help and serach on Variables it is quite comprehensive.

Declare variables in any formula you want to use them eg

global numbervar val1;
global stringvar val2;

Assign variable

val1:= 23
or val1:= formula

Display variable in its own formula,

global numbervar val1;

You may need to use this at the beginning of the formulae
whileprintingrecords;

Ian

 
Global is the default for variables, so you don't need to explicitly state global.

If you need LOCAL or SHARED, explicitly assign them as such.

-k
 
Thanks,
i use shared variables and was wonderfull, but now i can´t obtain totals, because my formulas is in the group footer, and don´t let me obtain total for that formulas.
thank you for all,


 
You only need to declare a variable as a shared variable if you're passing the value between subreport(s) and the main report.

If you have the subreport and formula calling the shared variable in the same section of the main report, the formula will not contain the updated value until the section AFTER the one in which the subreport is placed.

Naith
 
If you want technical assistance, you'll have to post technical information:

Crystal version
Database/connectivity used
Example data (show tables.fields and examples)
Expected output (show which section within Crystaql you need the output)

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top