Results 1 to 14 of 14
  1. #1
    LanieB is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    54

    0 divided by 0 = impossible..

    Hello All!



    I have created a database to store the results of our internal audits. They get audited on certain elements. My problem is... For example the element is File Folder Contents worth 5 points, if applicable, if they do not have a file folder I would put 0 earned out of 0 available. In the queries I am asking it to find the average of their elements but it is then taking earned divided by available which is 0/0 which equals #ERROR.

    Is there any way around this mathematical blunder?

  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
    A common solution:

    IIf(B = 0, 0, A/B)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    LanieB is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    54
    I'm really sorry to throw this on you. But I'm fairly new to access. Is this something I need to put in the SQL statement? or where would this IIf(B = 0, 0, A/B) need to be located.

  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
    I would assume that you have this in your query:

    SomeNewName: A/B

    so now you'd have

    SomeNewName: IIf(B = 0, 0, A/B)

    If that's not making sense, post the SQL of your existing query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    LanieB is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    54
    SELECT AirExport.Division, AirExport.[Audit Season/Year], Avg([FF_BookingSheet_AE]/[FF_BookingSheet_AA]) AS [File Folder Booking Sheet], Avg([FF_Organization_AE]/[FF_Organization_AA]) AS [File Folder Organization], Avg([DO_FileCopy_AE]/[DO_FileCopy_AA]) AS [File copy of all PHX invoices/credits issued], Avg([DO_Quotation_AE]/[DO_Quotation_AA]) AS [Quotation with back-up or CCP], Avg([DO_AES_AE]/[DO_AES_AA]) AS [AES Summary Report], Avg([DO_HAWB_AE]/[DO_HAWB_AA]) AS HAWB, Avg([DO_PHXdoc_AE]/[DO_PHXdoc_AA]) AS [PHX issued docs], Avg([DO_HazDec_AE]/[DO_HazDec_AA]) AS [Haz Dec], Avg([DO_SLI_AE]/[DO_SLI_AA]) AS [Shippers letter of instruction], Avg([DO_HazCheck_AE]/[DO_HazCheck_AA]) AS [Haz Mat check list], Avg([DO_BOL_AE]/[DO_BOL_AA]) AS [Inland bill of lading],


    This is just a glimpse of it... but this is how it goes to entire way, just different elements.

  6. #6
    LanieB is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    54
    AE = points earned
    AA = points available

    I then have it averaging and giving me an overall percentage.

  7. #7
    mejia.j88 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    are you seeing these results in a report?
    where does the #error appear?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I don't work much with Avg(). See if this works:

    Avg(IIf([FF_BookingSheet_AA] = 0, 0, [FF_BookingSheet_AE]/[FF_BookingSheet_AA]))
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    LanieB is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    54
    The error appears in the query, but when I run the report is is saying...

    "The expression is typed incorrectly, or is too complex to be evaluated. For example a numeric expression may contain too many compliacted elements. Ty simplifying the expression by assigning parts of the expression to variables."

    This error only appears when there has been a 0 out of 0 entered. Lots of trial a error to figure that one out Or if you know another reason why that may appear PLEASE let me know!

  10. #10
    mejia.j88 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    in every field of your report where you get #ERROR, put what pbaldy suggested as your control source; and change the field name accordingly.

  11. #11
    mejia.j88 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    also, out of curiosity, why is the available 0?

  12. #12
    LanieB is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    54
    Well that would indicate it was not applicable. Since I have fields that are adding the totals together on the form, there has to be something entered for those fields to total correctly. But then I get messed up in my queries and reports... I just can't win

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Did that work? If not, you may need to use the IIf() in a base query and then create another query that uses that query as its base instead of the table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    LanieB is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    54
    I am creating the query right now! I am doing it with just the IIF first and no averages, make sure it run smoothly with just one before adding the other.

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

Similar Threads

  1. Replies: 1
    Last Post: 10-01-2010, 04:44 AM
  2. Impossible to open more database
    By Grooz13 in forum Access
    Replies: 54
    Last Post: 08-06-2010, 05:17 PM
  3. Replies: 3
    Last Post: 08-03-2010, 02:24 PM
  4. Replies: 1
    Last Post: 02-01-2010, 06:12 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