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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Try to understand shared variable.

Status
Not open for further replies.

fredong

IS-IT--Management
Sep 19, 2001
332
US
Hi I am using CR V.10 and I have a formula below that I do not understand about shares varaible. I do have a field name PeriodDays in the database but Where can I find the true value of nTotPeriodDays in this formula? Is the prefix "n" represent something in CR? Thanks.


WhilePrintingRecords;

Shared NumberVar nTotPeriodDays;

{@CalcPeriodEarned} / nTotPeriodDays
 
Somewhere on your report Prior to this formula is another formula that is assigning a value to the shared variable, nTotPeriodDays

Check all the formulas in the Field explorer. If not there, then check the subreports the same way.
 
Your formula is calling a shared variable and then dividing a formula field {@CalcPeriodEarned} by the value of the variable.

You would need to look through the other formulas in the report until you found another reference to nTotPeriodDays to see how it is being assigned. Variable assignment is easily identifiable as the formulas will have the variable declaration (as in the formula above) and then

nTotPeriodDays := XXXX;

XXXX representing the value assigned to the variable.

A shared variable can be used within a report or sub report. The N prefix is not something specific to Crystal. It looks like whoever wrote this prefixes their variables with the type. In this case N could represent a numeric variable.
 
I found it. Thanks. Now is it possible to use a IF statement in the Whileprintingrecords like for example syntax below

WhilePrintingRecords;

Shared NumberVar nTotPeriodDays;
Shared NumberVar nTotPeriodRev;

if LOS =1

then

{@CalcPeriodEarned} / nTotPeriodDays

if LOT =1

then
{@CalcPeriodEarned} / nTotPeriodRev
 
You almost have it

if LOS =1

then

{@CalcPeriodEarned} / nTotPeriodDays

else if LOT =1

then
{@CalcPeriodEarned} / nTotPeriodRev

However, it may not be what you want. What do you want to do if LOS and LOT are equal to 1 or is that possible? What if both are not equal to 1?

-lw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top