Results 1 to 4 of 4
  1. #1
    TESMED is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    2

    #Num! Help!!!

    I'm very new to access but am running a report that I have tried for hours to try and correct but have not been able to solve the problem. My function is as follows:

    =Sum([Pos Cultures 1])/Sum([Total Samples 1])



    However sometimes Sum([Pos Cultures 1]) and Sum([Total Samples 1]) are equal to 0. I know that 0/0 will always return the #Num! because you can't divide 0 by 0. What can I do to get the result to be 0 if this is the case? I have tried several IIf expressions but can't figure it out. Also I don't know if this makes it any harder but this is supposed to give me a fraction to the 2nd decimal place (ex 1.00%).

    Let me know if I did not provide enough info. Again I am new so please be gentle.

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You might try
    Code:
    =IIF(Sum([Total Samples 1])=0,0,Sum([Pos Cultures 1])/Sum([Total Samples 1]))


    (You really shouldn't use spaces in names..... )

  3. #3
    TESMED is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    2
    Thank you!!!!! Problem solved.
    Could you elaborate on the spacing thing? Like I said I am new to access and got put in a position to create a database but I've never had any formal training on how to do it. However my database does function for our needs so I guess I survived.....for now.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Glad you got it working

    For object names, you should only use letters, numbers and/or the underscore. If you use spaces in names, you must enclose the names with brackets ([]).
    If you ever want to convert your dB to SQL, Oracle, etc , they tend to choke on spaces in names.

    Better names:
    TotalSamples1
    Total_Samples_1

    See http://access.mvps.org/access/tencommandments.htm

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

Tags for this Thread

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