Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Brandon, Manitoba, Canada
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nz doesn't work (A2KSR1)

    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?

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Nz doesn't work (A2KSR1)

    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])
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •