Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21845

[RESOLVED] strange db summation issue

$
0
0
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?? :(
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


Viewing all articles
Browse latest Browse all 21845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>