Senna,
Try this instead:
select (mytable)
nBalance = 0
scan
nBalance = nBalance + in - out
replace balance with nBalance
endscan
Your code keeps redoing the work over and over when you do the SELECT inside the loop.
>To count the balance field, usually I do like this :
>Select (mytable)
>Scan
> mrec=RECNO()
> SELECT SUM(out-in) FROM (mytable) WHERE RECNO()
> mbalance=total+in-out
> REPLACE balance WITH mbalance
>ENDSCAN
>
>THIS Procedure take to long, specially if I edited a record in the middle, so I have to start all over again.