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

Variable repeats last value??

Status
Not open for further replies.

Montana751

Programmer
Aug 14, 2001
64
US
Having Friday brain. I have a conditional variable that I am storing a balance in per detail line and want to show the total of all the balances for that day.

I wrote (@Display is a true condition. Formula name: @holder1:

Global NumberVar Balance;

If {@DISPLAY} then Balance := Balance + {AccountBalance.Balance};

The details returns:

Balance Variable
5 5
25 30
10 40

In the Group Footer, I get 50.

I put this variable in the detail section.
I wrote another formula (@Display) to display the results and put this in the Group Footer section:

Global NumberVar Balance := {@Holder1} ;

What am I doing wrong? (Crystal 8.5)

 
Do NOT place the incrementing formula in the Group Footer.

In the group footer place only the Display formula.

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Get rid of the := {@holder} in groupfooter formula, it's not needed

@balance sum

whileprintingrecords;
numbervar balance

Also, if it's not already there, I would add a "whileprintingrecords;" to the beginning of each of your formulas.

Instead of using a "test formula" and then using that formula in your adding formula, why not just test inside the formula.
Code:
whileprintingrecords;
numbervar balance;
if some condition is TRUE then
balance:=balance + {AccountBalance.Balance} else
balance:=balance




Mike
 
I put this formula in the DETAILS Section:

Whileprintingrecords;
Global NumberVar Balance;

If {@DISPLAY} = true
then Balance := Balance + {AccountBalance.Balance}
else Balance := Balance;

==========================
In the REPORT FOOTER Section, I put this:
whileprintingrecords;
NumberVar Balance;
=================================
I keep getting the last variable, not the total of all for the report. Whats wrong with my formulas????
 
What is in the {@DISPLAY} formula? Please post that.

Also, do you reference the Balance variable in any other formulas?

~Brian
 
The @Display formula reads:

IF {@SINGLEACCOUNT} OR OnLastRecord OR {AccountBalance.AccountId} <> Next ({AccountBalance.AccountId})
THEN True
ELSE False

===========================
The Balance variable is only used in the @Holder1 formula used in the Detail section and in the @DisplayBalanceTotals formula used in the Report footer section (definitions above in previous posts).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top