Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Using variables in reports Post Reply Post New Topic
Author Message
stonypaul
Newbie
Newbie
Avatar

Joined: 18 Feb 2010
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote stonypaul Replybullet Topic: Using variables in reports
     Posted: 18 Feb 2010 at 11:45am

Greetings,
I have been using CR for a few weeks and I must say I was sceptical at first because it just seemed like Excel on steroids, but now I am a convert - it truly is an impressive and addictive program.
My question is, is it possible to reference global variables in the actual body of the report, rather than just in formulae?
This option would certainly seem to cut down on the amount of formulas required, because you could use the if then else scenario several times over and assign values to several different variables in one formula.
I suspect that the answer will be no, because the variables just don't seem visible outside of the formulas.

Many thanks
Paul
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 18 Feb 2010 at 12:28pm

I dont know of a way to declare a variable outside of a formula. However, the formula can simple be used as a means to declare the variable, assign values, set its data type and scope, global, shared,etc. You may may want to think of the formula as the wrapper for the variable. The formula can hold any number of variables so long as they dont have the same name. To use those variables. you simply use another formula (again think wrapper) and reference the variable. You do that by declaring the variable using the same name and datatype. Then you can use that value in an anyway that is appropriate.

 
Regards,
 
John W.


Edited by jkwrpc - 18 Feb 2010 at 12:29pm
IP IP Logged
stonypaul
Newbie
Newbie
Avatar

Joined: 18 Feb 2010
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote stonypaul Replybullet Posted: 18 Feb 2010 at 1:07pm


OK, you pretty much confirmed what I suspected. Many thanks for taking the time to respond.
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 18 Feb 2010 at 1:44pm
I have successfully used variables to suppress sections or for formatting purposes. Not sure if that's what you're looking for though.
 
Just state the variable as so:
 
global numbervar nVariable=
 
Seems like you're going to be limited as to what you can actually do with it, but you can use them outside of a formula field. Of course, you would still have to make a formula that contains the variable and it would have to have a value.


Edited by FrnhtGLI - 18 Feb 2010 at 1:45pm
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum