FahadTiger
Member
- Local time
- Today, 03:24
- Joined
- Jun 20, 2021
- Messages
- 120
Hi Expert..
I used module to sum Amount according to CustomerNumber And CurrencyType
its working Good and give me the Result im main form of saleInvoice
but..when there are No Records in the table give me Error "invalid use of null".. in "TotalAmount = rs!TotalAmount"
How can I FIX that
I used module to sum Amount according to CustomerNumber And CurrencyType
its working Good and give me the Result im main form of saleInvoice
but..when there are No Records in the table give me Error "invalid use of null".. in "TotalAmount = rs!TotalAmount"
How can I FIX that
Code:
Function SumAmount(CustomerNumber As Long, CurrencyType As String) As Currency
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim TotalAmount As Currency
TotalAmount = 0
Set db = CurrentDb
strSQL = "SELECT Sum(Amount) AS TotalAmount FROM saleDetails WHERE CustomerID = " & CustomerNumber & " AND CurrencyType = '" & CurrencyType & "'"
Set rs = db.OpenRecordset(strSQL)
If Not rs.EOF Then
TotalAmount = rs!TotalAmount
End If
rs.Close
db.Close
Set db = Nothing
SumAmount = TotalAmount
End Function