I have a datagrid that the user can edit, delete. add etc and it works fine.
The total from one currency column needs to be automaticly updated after the user makes changes and he clicks a Save cmdbutton. At the moment with this code I can only make it work by using a seperate command button to update the total. I would like to do it without using another cmdbutton to update the total. The error I get if I include the code anywhere else is you cannot add a empty row. Hopefully someone can show me how to modifiy this code.
visual basic code:
If Adodc2.Recordset.RecordCount <> 0 And Adodc2.Recordset.BOF = False And Adodc2.Recordset.EOF = False Then
Dim fmtCurr As New StdDataFormat
fmtCurr.Format = "Currency"
Set DataGrid1.Columns(1).DataFormat = fmtCurr
Dim rs As ADODB.Recordset
Dim dSum As Double
Set rs = Adodc2.Recordset.Clone
rs.MoveFirst
Do Until rs.EOF
If IsNumeric(rs("ValueChgOrder"
) Then _
dSum = dSum + rs("ValueChgOrder"
rs.MoveNext
Loop
Set rs = Nothing
txtTotal.Text = FormatCurrency(dSum)
Else
txtTotal.Text = ""
End If
Thanks for any and all help
The total from one currency column needs to be automaticly updated after the user makes changes and he clicks a Save cmdbutton. At the moment with this code I can only make it work by using a seperate command button to update the total. I would like to do it without using another cmdbutton to update the total. The error I get if I include the code anywhere else is you cannot add a empty row. Hopefully someone can show me how to modifiy this code.
visual basic code:
If Adodc2.Recordset.RecordCount <> 0 And Adodc2.Recordset.BOF = False And Adodc2.Recordset.EOF = False Then
Dim fmtCurr As New StdDataFormat
fmtCurr.Format = "Currency"
Set DataGrid1.Columns(1).DataFormat = fmtCurr
Dim rs As ADODB.Recordset
Dim dSum As Double
Set rs = Adodc2.Recordset.Clone
rs.MoveFirst
Do Until rs.EOF
If IsNumeric(rs("ValueChgOrder"
dSum = dSum + rs("ValueChgOrder"
rs.MoveNext
Loop
Set rs = Nothing
txtTotal.Text = FormatCurrency(dSum)
Else
txtTotal.Text = ""
End If
Thanks for any and all help