>>>Dear Bhavbhuti Nathwani
>>>
>>>No body wrote any code in this thread. Every body try to present suggestions.
>>>I ask if thread poster knows the codes then what he needs to post any thread.
>>
>>It's easy to write the code - it's much harder to design the tables (or even temporary cursors) to have as little code as really necessary.
>>
>>There are several things to consider in your case (and yes, I had my running totals to do in my time). First, can you trust the totals column? Is it possible that a record may come somewhere in the middle and you'd have to recalculate everything from that point on? Is it possible that a record may be deleted (and then recalculate everything again)? Also, are you sure the records will always show in this order? If there's any chance that they may show in a different order, then you'd have to recalculate for the new order.
>>
>>If it will always be by date, and there is one and only one record per date, then it's simple:
>>
>>
>>lnTotal=0
>>lnOpening=0
>>scan
>> lnTotal=lnTotal+receipt-payment
>> replace opening with lnOpening;
>> , total with lnTotal
>> lnOpening=lnTotal
>>endscan
>>
>>If any record changes (add new, change existing, delete... anything), you would need to run this again.
>__
>
>Dragan,
>
>Seems to me the 'opening' is in every record already. How else does he know the balance?
See how many ifs have I put before my code? There's so many things which may influence the outcome and, in the end, make any solution perfect or perfectly ridiculous... things which we don't know, like "is this a cursor created on the fly or is this a real transactional table", "is this updated sometimes?" etc etc.