Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

sum of a field

Hi experts, Is it possible to get the sum of a certain fields during Insert execution? Please see my code below where I tried to get the sum of a credit but the codes is not working. Any help please!

Public Sub SaveSalesPOS(rct, record, disc, tot, edate, cid, credit, check, cuscode)
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

        cn.Execute ("Insert into CustomersLedger(CustomersCode,iDate,TransactionNumber,Credit,Debit,Balance) Values('" & cuscode & "','" & _
                    edate & "','" & record & "'," & credit & "," & "0" & "," & Sum(SalesPerTrx.credit) & " where CustomersCode='" & cuscode & "')")
        
Set rs = Nothing
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Whing Dela Cruz

ASKER

Thank you Ryan, I really need 2 actions here..