Ian,

>I have a problem with a project I am working on. I have a database
>table containing financial transactions:
>
>id    account    date    description    amount_in    amount_out
>
>I filter the table based on things like account, date ranges etc and
>then show the results in a DBGrid. The user can click on a column to
>change the sort. I need to show the current balance on each row so:
>
>balance = previous_balance + (amount_in - amount_out)
>
>This isn't a big problem until the user scrolls the grid or changes
>the sort field, then the balance column changes as the balance on the
>previous row is wrong.

If all you want to do is display the output in the grid without the need to
change the data, I would just use a TQuery and TStringGrid to display
the data. Your loop that adds rows to the grid could calculate the balance
any way you want. If users need to change sort order, you can write your
own code to handle clicks on the top row and either sort the loaded grid
or just change the ORDER BY in the SQL and reload.

Glenn Lawler
www.incodesystems.com

Reply via email to