Results 1 to 4 of 4
  1. #1
    frustratedwithaccess is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Oct 2014
    Posts
    35

    #Num! and #Div! errors

    Hello All,



    I am attempting to run a simple calculation involving 3 columns:

    - ColumnA
    - ColumnB
    - ColumnC

    ColumnC is equal to: [ColumnB]/[ColumnA]

    Both columns have a range of numbers from 0 up to approximately 800. In my database, there are records where zeros occur in both ColumnA and ColumnB. As well, there are records where ColumnB has a number greater than 0, but ColumnA is 0 (and vice versa) in the same record. In these cases, I end up with #Num! and #Div! errors. I need to keep the "zeros" as they are important important data.

    Hope someone can help.

    Cheers!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Division by 0 is mathematically not possible, hence the #Div! error. I don't know why the #Num! error.

    Can handle 0 in denominator with an IIf expression.

    [ColumnB]/IIf([ColumnA]=0,1,[ColumnA])

    or force the calc to return Null if 0 in denominator.

    [ColumnB]/IIf([ColumnA]=0,Null,[ColumnA])
    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.

  3. #3
    frustratedwithaccess is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Oct 2014
    Posts
    35
    Thank you for the response! I will give that a go.

    As well, the #Num! error is from dividing 0 by 0.

  4. #4
    frustratedwithaccess is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Oct 2014
    Posts
    35
    Just tried [ColumnB]/IIf([ColumnA]=0,1,[ColumnA]

    Works like a charm

    Thanks again!

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

Similar Threads

  1. Errors
    By Thompyt in forum Programming
    Replies: 3
    Last Post: 10-31-2014, 01:29 PM
  2. Replies: 4
    Last Post: 06-21-2014, 05:43 AM
  3. New Table Errors
    By css1270 in forum Access
    Replies: 11
    Last Post: 12-21-2011, 11:27 AM
  4. Replies: 10
    Last Post: 07-25-2011, 12:07 PM
  5. SQL that errors in VB
    By Wayne311 in forum Programming
    Replies: 3
    Last Post: 02-14-2011, 10:17 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