Khubaid, if it is for a report, it is much easier to manage this information through report variables.
>these code can be changes into sql
>
>Select accounts
> Locate For code=thisform.code.value
> opbl = opdr-opcr
> Select acctran
> Set Order To date
> Set Filter To
> Set Filter To code=thisform.code.value
> Goto Top
> Replace balance With 0 All
> Goto Top
> blnc = opbl
> Do While !Eof()
> blnc = blnc+debit-credit
> Replace balance With blnc
> Skip
> Enddo
>
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)