Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread sum record?
Sat, Nov 3 2007 6:02 PMPermanent Link

"Andrej Bivic"
I have in a DBgrid at least one record in a query (the first one) in which I
sum all values of all other records. If I add or remove a record, the first
(sum) record should be recalculated. What is the best aproach?

Andrej

Sat, Nov 3 2007 6:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Andrej,

<< I have in a DBgrid at least one record in a query (the first one) in
which I sum all values of all other records. If I add or remove a record,
the first (sum) record should be recalculated. What is the best aproach? >>

How are you summing the value to begin with ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Sun, Nov 4 2007 5:56 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Andrej


I'd look at the footer properties in the TDBAdvGrid and a query in the after delete or post events of the query.

Roy Lambert
Sun, Nov 4 2007 8:09 AMPermanent Link

"Andrej Bivic"
Here is the thing:
First, I have only one record with a preset value (let say 1000). Then I add
a record and enter a value (let say 200). What I want is, that the sum off
all records is always 1000 (first entered), so the value of the first sould
be changed (to 800 in the case).

Andrej

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:4F58904F-5028-4FEE-81DD-5CF298245307@news.elevatesoft.com...
> Andrej,
>
> << I have in a DBgrid at least one record in a query (the first one) in
> which I sum all values of all other records. If I add or remove a record,
> the first (sum) record should be recalculated. What is the best aproach?
>  >>
>
> How are you summing the value to begin with ?
>
> --
> Tim Young
> Elevate Software
> www.elevatesoft.com
>

Sun, Nov 4 2007 11:58 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Andrej


Don't go there. All you are doing is building a mass of trouble for yourself.

You also posted in the TMS newsgroups so I presume you're using their grid. Switch from the data aware grid to the TAdvStringGrid. FIll the grid yourself (its a doddle really). Then you can use the inbuilt events and each time a value is changed just iterate through the grid adding up the new values and posting to the first row. You can even have the first two rows as fixed which will make your special row stand out.

Roy Lambert
Sun, Nov 4 2007 1:08 PMPermanent Link

"Andrej Bivic"
Tnx for the advice. I really use TMS components (nice spot!) Smile
Andrej

"Roy Lambert" <roy.lambert@skynet.co.uk> wrote in message
news:534BD4FC-80B3-42C9-8DCC-8EF4F2DC49C5@news.elevatesoft.com...
> Andrej
>
>
> Don't go there. All you are doing is building a mass of trouble for
> yourself.
>
> You also posted in the TMS newsgroups so I presume you're using their
> grid. Switch from the data aware grid to the TAdvStringGrid. FIll the grid
> yourself (its a doddle really). Then you can use the inbuilt events and
> each time a value is changed just iterate through the grid adding up the
> new values and posting to the first row. You can even have the first two
> rows as fixed which will make your special row stand out.
>
> Roy Lambert
>

Image