[Originally posted by Yousuf]

Dear Guys,I want to sum a column of datagrid. I tried
the following code. But it never refreshes the result.
It shows the result after two events.Is there anycode
to solve this problem. Actually I wanted to sum the
datagrid directly without using sql. Can you post
sample code please. Thanks a Lot in advance.
Here is my code:-
Private Sub DataGrid1_KeyPress(KeyAscii As Integer)

If KeyAscii = vbKeyReturn Then
KeyAscii = 0
If DataGrid1.Col = 4 Then 'Price column
Dim totals As New ADODB.Recordset
Call connection3
Totaltxt.Text = ""
totals.Open "select sum(PrdPrice * qty) as t
from TempInv", con, _
adOpenDynamic, adLockBatchOptimistic
If IsNull(totals!t) Then
Exit Sub
End If
Totaltxt.Text = totals!t
End if
End if
End sub