hey, im trying to read the values of the amount field of a table and display its total..
but there seems to be some silly error in the code which is giving strange results usually the 2nd time i run the operation., for example when there are 2 entries 500 and 500
it shows 500500 501000(dunno how, 500 & 1000 or whatever)
what am i dong wrong here?? :(
but there seems to be some silly error in the code which is giving strange results usually the 2nd time i run the operation., for example when there are 2 entries 500 and 500
it shows 500500 501000(dunno how, 500 & 1000 or whatever)
what am i dong wrong here?? :(
Code:
Dim exptotal As Long
exptotal = 0
Dim adousers As New ADODB.Recordset
If adousers.State = adStateOpen Then adousers.Close
adousers.Open "Select * From Expense where Date BETWEEN '" & date1 & "' AND '" & date2 & "'", con, adOpenStatic
Do Until adousers.EOF
exptotal = exptotal + Val(adousers.Fields("Amount").Value)
adousers.MoveNext
Loop
expense.Sections("Section5").Controls("lblexp").Caption = exptotal