Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

summing columns on a datagrid

Status
Not open for further replies.

GeorgeDurkee

Programmer
Feb 22, 2000
47
US
I have a datagrid that has number of rows. The columns are all numbers and I want to generate a total for each column as well as each row...
like this

Column1 column 2 column 3 total
1 1 1 3
2 1 1 4
1 2 .5 3.5
total 4 4 2.5 10.5

My problem is moving down the rows. I cannot find a move next or set row or anything else that lets me down the grid. I can detemine how many rows I have by Approxcount, but not how to move.

Any ideas?

Thanks
 
Hi GeorgeDurkee,

I believe the DataGrid is a bound control. Therefore, you would iterate through the datasource that the grid is bound to.

Let's assume your grid is named DataGrid1 and you bind it to an ADO Data Control name Adodc1. Here's how you'd achieve this.

Code:
Set DataGrid1.DataSource = Adodc1
Adodc1.Recordset.MoveFirst
Do While Not Adodc1.Recordset.EOF
    myvariable = myvariable + Adodc1.Recordset.Fields("Field1")
    Adodc1.Recordset.MoveNext
Loop


MapMan [americanflag]

Assume nothing, question everything, be explicit not implicit, and you'll always be covered.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top