• Nz doesn’t work (A2KSR1)

    Author
    Topic
    #362492

    I have a qery that performs a sum on two controls and provides a percentage through an expression. Of course if either or both of the two controls have a null field I get an error so I wrote the following:
    Percent:Nz([control1],0)/Nz([control2],0)
    but it doesn’t work. It still shows error when both fields are null. How can I have 0/0 or null/null to show zero?

    Viewing 0 reply threads
    Author
    Replies
    • #550592

      If both fields are null, your use of the Nz function will cause a divide by zero error. You’re going to have to use an IIf() like this:

      Percent: IIf(IsNull([control2]),0,nz([control1])/[control2])

    Viewing 0 reply threads
    Reply To: Nz doesn’t work (A2KSR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: