datatable.compute with datagrid [question]

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

From the help menu, I know that I can use myTable.compute the get the sum
amount.
Now myDatagrid 's datamember is myTable, I put the following code in my
datagrid.currentcellchanged.
and I found a little problem , As the user input the total in the 1st row,
and press 'tab' to another column .
It can't sum up the 1strow 's total, If I input the data in the 2nd row and
pres s'tab' , It will sum the 1st row but not 1st row & 2ndrow.
If I move to the 3rd row, it will sum up both 1st row 2ndrow.
anybody got idea ? Thanks a lot

Private Sub ComputeBySalesSalesID(ByVal myDataSet As DataSet)
Dim myTable As DataTable
myTable = myDataSet.Tables("Orders")
Dim objSum As Object
objSum = myTable.Compute("Sum(Total)", "EmpID = myID")
End Sub
 
Agnes,

You cannot do that with the compute (or there should be a trick I don't
know). However you can do that of course row by row, where you have to set
everytime the previous (easily to store as prevrowIndex) to zero.

I hope this helps?

Cor
 
Back
Top