Search code examples
footer

How to set the value of a textbox to 0 “Zero” in a continues form footer while the detail of the form has no data MS Access


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.


Solution

  • 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