Results 1 to 4 of 4
  1. #1
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283

    Division by zero error

    Hello, I'm trying to write a sub query and I keep getting the division by zero error. I used an IIf statement but it's not working. Here's what I have:



    IIf([Contracts Completed]=0,0,([Contracts Completed]/([Producing Time]/60)))

    If you guys could help me out I'd appreciate it.

    Thanks

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are checking the wrong part.

    There is no need to check if the numerator is zero. The answer will already be zero if this is the case (zero divided by any non-zero number is zero).
    You need to check if the denominator is zero , i.e.
    Code:
    IIf([Producing Time]=0,0,([Contracts Completed]/([Producing Time]/60)))

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Don't understand why you are testing for 0 in [Contracts Completed] - it is the numerator.
    Is this expression the denominator for a more complex expression?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283
    Thanks Joe!

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

Similar Threads

  1. Replies: 3
    Last Post: 09-25-2015, 12:29 PM
  2. division on vba with formating
    By joshynaresh in forum Forms
    Replies: 5
    Last Post: 10-23-2013, 06:04 AM
  3. #Num! error division by 0
    By smc678 in forum Access
    Replies: 5
    Last Post: 10-14-2013, 11:41 AM
  4. division by 0
    By kwooten in forum Queries
    Replies: 5
    Last Post: 03-19-2012, 04:37 PM
  5. Division by zero error on a query
    By thorwood in forum Access
    Replies: 3
    Last Post: 05-19-2011, 07:20 AM

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