Results 1 to 4 of 4
  1. #1
    nigelbloomy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    51

    #error in my query, is NZ() not working?

    I have a field in a query that is giving me #error. The two fields it is using (SumOfSumOfEXT_COST, and SumOfSumOfACT_HOURS) are both calculating to have a value of 0.

    Code:
    HR_RATE: NZ([SumOfSumOfEXT_COST],0)/NZ([SumOfSumOfACT_HOURS],0)
    Does Access spit out an error when it does 0 divided by 0? How do I turn that error into a 0?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Yes, you'll get an error if the divisor is 0. The typical solution is using the IIf() function to test for it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    nigelbloomy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    51
    That works perfectly. I hadn't planned on $0 values being in either field. Thank you for the quick reply. Now I get to go find out why there is a $0 value coming into my query. At least the whole thing won't be crashed while I look for the real problem.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 05-30-2012, 12:32 PM
  2. Help please! iif not working in query!
    By ham355 in forum Queries
    Replies: 4
    Last Post: 02-16-2012, 05:05 AM
  3. Import not working - no error
    By stlbryson in forum Import/Export Data
    Replies: 10
    Last Post: 07-04-2011, 02:02 PM
  4. codes for working days error
    By Harry in forum Programming
    Replies: 21
    Last Post: 10-15-2010, 02:32 PM
  5. combobox.dropdown event not working after error
    By perlyman in forum Programming
    Replies: 1
    Last Post: 04-02-2010, 06:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums