0

i have a column of datatype money in mssql 2k5... colX...

i want to show this colx in two columns, col1 and col2 according to colY in crystalreport as:

res = 100.00
col1       col2     col3
10.00      0        90.00
0          1.00     91.00
0          5.00     96.00
50.00      0        46.00 
.
.

but what i am getting now is:

res = 100.00
col1       col2     col3
10.00      0        100.00
0          1.00     100.00
0          5.00     100.00
50.00      0        100.00 
.
.

Following is the formula i am using for col3...

    dim ob
    ob={TABLE.res}
    WhileReadingRecords
    if {TABLE.colY}="C" then
        ob=ob-{TABLE.colX}
        formula=ob
    else
       ob=ob+{TABLE.colX}
       formula=ob
    end if

Please do answer if u have any solution or reference...

Jamal Abdul Nasir
  • 2,557
  • 5
  • 28
  • 47
  • What are the values for columns X and Y? Are they 'col1' and 'col2' in your example? What is the logic that you want applied? – craig Feb 05 '12 at 18:54
  • colY is a column on which i put a condition. and colX is the amount which split in two columns (col1 and col2). on the basis of colY i am subtracting or adding its value to variable ob. Simply putting, this is the carrying balance forward. The same as in ledger. – Jamal Abdul Nasir Feb 05 '12 at 19:11
  • Please include sample X and Y values in your examples so we can follow your logic. – craig Feb 06 '12 at 04:28

1 Answers1

0

the above mentioned issue is fixed...

i just declared a global variable in the header section of the report...

Global ob as currency
ob={TABLE.res}
formula=ob

and the balance forwarding logic remains in its place (detail section of the report) with the one change made...

Global ob as currency
WhileReadingRecords
if {TABLE.colY}="C" then
    ob=ob-{TABLE.colX}
else
   ob=ob+{TABLE.colX}
end if
formula=ob

Now i am getting what i needed... as;

res = 100.00
col1       col2     col3
10.00      0        90.00
0          1.00     91.00
0          5.00     96.00
50.00      0        46.00 
.
.
Jamal Abdul Nasir
  • 2,557
  • 5
  • 28
  • 47