Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sum Columns in grid

615 views
Skip to first unread message

NeoX

unread,
Jul 8, 2008, 11:50:02 PM7/8/08
to
Hallo any one,I'm totally new in Visual FoxPro, I want to know how to sum
total value in whole 1 columns on the grid


thank you


Stefan Wuebbe

unread,
Jul 9, 2008, 3:12:20 AM7/9/08
to

"NeoX" <t_f...@ufo-indonesia.com> schrieb im Newsbeitrag
news:eYRkfbX4...@TK2MSFTNGP02.phx.gbl...

> Hallo any one,I'm totally new in Visual FoxPro, I want to know how to sum total value in
> whole 1 columns on the grid

Do you want something like a "running totals" column? If so, you can do
a SQL self-join, e.g.:
CREATE CURSOR temp (idField Int, amount Num(15,2))
INSERT INTO temp VALUES (1, 11.3)
INSERT INTO temp VALUES (2, 8.7)
INSERT INTO temp VALUES (3, 10)

SELECT T1.idField, T1.amount, SUM(T2.amount) ;
FROM temp T1 ;
JOIN temp T2 ON T2.idField <= T1.idField ;
GROUP BY 1, 2 ORDER BY 1IOW, when you want to display any calculated columns in a
grid, your best bet may be to create a (parameterized) Local View on the actual data and
the use that view as yourGrid.RecordSource.hth-Stefan


Anders Altberg

unread,
Jul 15, 2008, 8:48:01 AM7/15/08
to
Assuming the third column contains the values you want to sum and that the
cursor is TableBuffered (5)

Function Grid.AfterRowColChange
Lparameters nColIndex
If nColIndex = 3 And This.RowColChange>0
Local lcCol
lcCol=This.Columns(3).ControlSource
Select Sum(&lcCol) From (This.RecordSource) With (Buffering=.T.) Into Array
aTmp
Thisform.Text1.Value=aTmp(1)
Endif

-Anders

"NeoX" <t_f...@ufo-indonesia.com> wrote in message
news:eYRkfbX4...@TK2MSFTNGP02.phx.gbl...


> Hallo any one,I'm totally new in Visual FoxPro, I want to know how to sum
> total value in whole 1 columns on the grid
>
>
>

> columnname
> thank you
>
>
>
>


0 new messages