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

How to come-up with summation of numbers

$
0
0
I'm trying to do a report using Excel such like this:

Client1 = 3000
Client2 = 2000
Client3 = 1000

from my MS Access database containing the following data:

Client1 = 1500
Client1 = 1500
Client2 = 1000
Client2 = 1000
Client3 = 500
Client3 = 500

Therefore my report is their summation. But unfortunately i cant

have the summation but instead i just displaying the first value. My

code goes like this: Please help me to resolve my problem. Thanks.

Set rs = New ADODB.Recordset
rs.Open "Select * from transactions where refdate >=#" & DTPicker1.Value & "# and refdate <=#" & DTPicker2.Value & "#", cnn, adOpenKeyset, adLockOptimistic
Do Until rs.EOF
DUMMYACCTNO = rs!acctno
If DUMMYACCTNO = rs!acctno Then
Set rs1 = New ADODB.Recordset
rs1.Open "Select * from transactions where acctno = " & Sheet.Range("B" & CStr(x)).Value & " and refdate >=#" & DTPicker1.Value & "# and refdate <=#" & DTPicker2.Value & "#", cnn, adOpenStatic, adLockOptimistic
Dim CNT As Integer
CNT = rs1!acctno
If CNT > 1 Then
AMT = CDbl(rs1!GROSS + (AMT))
Sheet.Range("G" & CStr(x)).Value = AMT
Else
Sheet.Range("G" & CStr(x)).Value = rs1!GROSS
End If
End If
TOTALAMT = CDbl(rs!GROSS + TOTALAMT)
rs.MoveNext
x = x + 1
AMT = Empty
Loop

Viewing all articles
Browse latest Browse all 21970

Trending Articles



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