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!

Sum a column within datagrid based on current record

Status
Not open for further replies.

Vandy02

Programmer
Jan 7, 2003
151
US
I have an application that hits a database and pulls over two tables "Orders" and "Order Details" into one dataset link by OrderID. I have the data of the "Orders" table appearing in textboxes with navigation buttons using cmOrders.Position to navigate through the data. I have the "Order Details" data based on the OrderID appearing within a datagrid. All works well. However, I would like to be able to sum the values in a column(QTY) of the "Order Details" table based on the current OrderID...

Orders Order Details
OrderID 2 OrderID Qty
2 10
2 20

SUM = 30

I hope this makes since....
Thanks
 
I would work with the underlying dataset and not the datagrid.

Try something like this...

dim r as datarow
dim intSum as int32

for each r in mydataset.tables(0).rows

if r.item("OrderID")= textbox1.text then
intSum = intSum + cint(r.item("Qty"))
end if

next
return intSum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top