Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


How can i use global variables

How can i use global variables

How can i use global variables

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!!!!

RE: How can i use global variables

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

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.


RE: How can i use global variables

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


RE: How can i use global variables

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.


RE: How can i use global variables

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,

RE: How can i use global variables

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.


RE: How can i use global variables

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)


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close