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

Shared Variables

Status
Not open for further replies.

Wabush

Programmer
Jan 15, 2001
31
0
0
US
I have a report that is grouped by bank account number and in the details section are all the transactions that occured in the time period of the report. In the details, I created two variables to store the rate of interest based on the balance in the account. If the balance is above zero, I assign the rate to the creditintrate. The other formula assigns the debitintrate if the balance is below zero.
Then in the group footer, I placed this formula to calculate prime, and it is returning 0 even though when I display the variables by themselves in the footer, it shows the correct value.

shared numberVar creditintrate;
shared numbervar debitintrate;
local numberVar prime;
if debitintrate > 0
then
prime = creditintrate + 2.25
else
prime = debitintrate - 1;
prime
 
You must use ":=" to assign a value in a formula,
e.g. prime := creditintrate + 2.25
 
It isn't a problem with shared variables...but rather a problem of number assignment.

Actually Shared variables are not necessary as you are not passing these numbers back and forth between a superort(s).

so this version of the formula should work:

WhilePrintingRecords;
numberVar creditintrate;
numbervar debitintrate;
numberVar prime;

if debitintrate > 0 then
prime := creditintrate + 2.25
else
prime := debitintrate - 1;

prime;

NOTE: 1. ":=" is assignment "=" is comparison
2. remove the shared and Local from your variable
designation...they are not necessary here.
3. You should consider adding "WhilePrintingRecords"
to your formulas. I do this to instruct Crystal
when to perform the formulas. The only time I
don't use this is for Grouping or Summary formulas.
Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top