Results 1 to 6 of 6
  1. #1
    BiotinX is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2020
    Posts
    7

    #Num! Error

    All -

    I have a sheet that has cells that have data (numbers) and some that do not. When doing a sum, I'm getting a #Num! error I believe because access is reading the "empty" cell as 0 and consequently giving 0/0 = !Num#.

    To eliminate the error (because I'm trying to link this query to an excel sheet) I have tried IsError nested in an if statement, which did not work. I also tried using IsEmpty to distinguish between an empty cell and a cell with a variable, but both return the same value.



    Help!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    you would have to query only the values with non zeros. then divide.

  3. #3
    BiotinX is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2020
    Posts
    7
    Sometimes the values are zero and sometimes they are not, I don't want to make a separate query because that would jack up my column organization in the excel sheet this feeds into. There has got to be a way to suppress the !Num# or turn it into a 0.

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    This error is being raised by a query?
    Post sample of data where it works and a sample where it doesn't, and the query expression that isn't working or try something like
    IIF(valueB = 0,"",valueA/valueB) or Null instead of "" in such an expression.

    IsEmpty is for testing if an object variable is empty or contains an object.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    BiotinX is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2020
    Posts
    7
    Yes, I have query that's doing some math. Here what I have in the query -
    Q21: Sum(IIf([q_Compile3]![Q21_Score]=4,1,0))/Count([q_Compile3]![Q21_Possible])*100

    I have a lot of fields with this code, anywhere between 25-100 depending on the number of questions on the test. The error comes in when there is no question 26 for example, [q_Compile3]![Q26_Score] and [q_Compile3]![Q26_Possible] have no value in that field.

    I'm trying to build my input to this query so that the empty fields will be populated by zeros. Then I can add an additional if statement before the calculation above.

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    So if the first value isn't 4 (can be anything else) you'll end up with 0. Then isn't the problem with the latter part? You can't divide by 0 so 'empty' fields being 0 won't help. Maybe you need an expression that divides if the reference is greater than 0 but does nothing if it is 0. Could it be negative also?
    Maybe
    Sum(IIf([q_Compile3]![Q21_Score]=4,1,0))/IIF(Count([q_Compile3]![Q21_Possible])> 0,Count([q_Compile3]![Q21_Possible])*100,???)
    ??? is whatever you'd use as a divisor - perhaps 1. Perhaps null.

    You could consider writing a function that returns a variant and call it from the query field. Then if the function sees a zero or null in the second part, it could simply return null to the field (assuming the query/table field allows that) and not do any math at all. I suppose you could find a way to write your expression to do the same, but I think a function is a bit more elegant and often more versatile.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 6
    Last Post: 02-03-2020, 07:09 PM
  2. Replies: 5
    Last Post: 07-15-2019, 10:20 AM
  3. Replies: 1
    Last Post: 07-26-2016, 06:34 AM
  4. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  5. Replies: 0
    Last Post: 07-16-2012, 05:42 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