[RESOLVED] How to carry forward a field value to next row
Hi All
I extract these below matirx resultset into my crystal10 ,,but i need find a increamental value of the selected Dr2 & Balance formula field.
Dr2 = Dr1 + {previous_Balance}
Balance = Dr2 - Cr1
Expected resultset in Crystal:
field1 Dr1 Cr1 Dr2 Balance
1 100 50 0 50
2 100 60 150 90
3 100 0 190 190
4 0 50 190 140
I have create 2 formula_fields to called Dr2 & Balance field BUT i failed to figure out how to get the result as above resultset.
Please advice.
Thanks.!!!
rgds
JaS____\ /
:(
Re: How to carry forward a field value to next row
Using Global variables you can create running totals fields. Try these two formulas, written in Crystal Syntax.
Code:
DR2 Formula
Global currencyVar DR;
Global currencyVar BAL;
If RecordNumber = 1 Then
DR:= 0
Else
DR:= BAL + {Testing.DebitAmount};
DR
Code:
Balance Formula
EvaluateAfter ({@DR});
Global currencyVar DR;
Global currencyVar BAL;
If RecordNumber = 1 Then
BAL:= {Testing.DebitAmount}-{Testing.CreditAmount}
Else
BAL:= DR - {Testing.CreditAmount};
BAL
Re: How to carry forward a field value to next row
thanks for your input brucevde,,,will try it later.
Re: How to carry forward a field value to next row
Great !! your formula worked BUT how do i reset value of Dr2 and Balance if i wanna break down by field1 ?
field1 Dr1 Cr1 Dr2 Balance
1 100 50 0 50
1 100 60 150 90
2 100 0 100 100
2 0 50 100 50
2 50 50 100 50
Thanks in advance
Rgds
JaS
Re: How to carry forward a field value to next row
Create a new formula with the following code and place it in the Group Header section.
Code:
WhilePrintingRecords;
Global currencyVar DR;
Global currencyVar BAL;
DR := -999;
BAL:= -999;
You will need to adjust the other formulas to account for the Group change as well, ie
If RecordNumber = 1 Or DR = -999 Then
However, something is inconsistent in your example (or my thinking).
Shouldn't the value of DR2 in the first record of the second group be 0.
Re: How to carry forward a field value to next row
thanks for your input. Balance is a value based on formula Dr1-Cr1 and will carry into next row and then sum it together with with Dr2 with formula ( Dr1+Balance) at row2 till end of record.
Will try it again later ,,,thanks a lot.
Re: How to carry forward a field value to next row