Board index » delphi » Sum Grid Columns

Sum Grid Columns

I'm trying to sum a dbgrid column that may have multiple rows.

How do I traverse thru the dbgrid and sum the one column up.

Thanks
Bill Benko

 

Re:Sum Grid Columns


Quote
>I'm trying to sum a dbgrid column that may have multiple rows.
>How do I traverse thru the dbgrid and sum the one column up.

You do not traverse a grid you can iterate through the dataset that the grid is
attached to.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Sum Grid Columns


I'm using cache updates in master / detail for sales orders.

I need to get the total of parts from the detail records in the grid inorder
to post the master record and then post the detail records.

I guess I could apply the updates to the detail records and then run the sum
query to get the total for the master order and then applyupdates to the
master..

It would just be easier if I could total up the grid column add the total to
the order and apply updates to bothe the master and detail records.

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:9bj2ct8il64fu55dg45uonbn0m7kusdi9h@4ax.com...

Quote
> >I'm trying to sum a dbgrid column that may have multiple rows.
> >How do I traverse thru the dbgrid and sum the one column up.

> You do not traverse a grid you can iterate through the dataset that the
grid is
> attached to.

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:Sum Grid Columns


Quote
>I'm using cache updates in master / detail for sales orders.

>I need to get the total of parts from the detail records in the grid inorder
>to post the master record and then post the detail records.

Just because you are using cachedupdates doesn't mean you can not iterate
through the table with out applying the updates.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Sum Grid Columns


I'm using  a query for the detail records with cached updates.
If I post the record ( still not applying the updates ) and run a query to
sum the prices I only get the the prices that were there when I first opened
the query.  It does not pick up the record that I just posted that should be
in the cache.

Is ther something special to get the cached records ?

I really appreciate the time you have spent helping me.

Thanks
Bill

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:v125ct0g9133m3tgfcs05ia8t37082dm5h@4ax.com...

Quote

> >I'm using cache updates in master / detail for sales orders.

> >I need to get the total of parts from the detail records in the grid
inorder
> >to post the master record and then post the detail records.

> Just because you are using cachedupdates doesn't mean you can not iterate
> through the table with out applying the updates.

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:Sum Grid Columns


Quote
>I'm using  a query for the detail records with cached updates.
>If I post the record ( still not applying the updates ) and run a query to
>sum the prices I only get the the prices

Iterate through the query

nbsum:=0;
With query1 do begin
  first;
    While not Eof Do Begin/
    nbsum := nbsum+fieldbyName('bribes').asfloat;
    next;
  end;//while
end;//with
end;
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads