I have a continues form in which I used the if()
, IsNumeric()
, isnull
and SUM()
functions to calculate the total amount of the records if exist in the details, else return me 0 (zero):
if(IsNumeric(Tr_Amount), SUM(Tr_Amount), 0)
if(isnull(Tr_Amount), sum(Tr_Amount), 0)
However, it is not working fine. While it has no records in in details it doesn't return 0 in the textbox, but it if it has some records it returns the total amount.
I found the answer: I used two text box SUM and SUMTotal, sum is invisible
if there is no records then set the text box to 0 else set to sum of records
Private Sub Form_Load()
If Me.RecordsetClone.RecordCount = 0 Then` Me.SUMTotal = 0 Else Me.SUMTotal = Me.SUM End If End Sub