Results 1 to 6 of 6
  1. #1
    countingguru is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    17

    Calcuated field in Access quey contributes to crashing Excel table upon import !

    I am going nuts on this issue!



    I have a simple calculated field (As "Ratio") that is readable in Access 2010 query, but crashes in Excel upon importing/running the query in an .xlsx table.
    ERROR MESSAGE in EXCEL: "The query did not run, or the database table could not be opened...check database server..contact your database administrator.."

    I am simply taking the cost amounts of each project record (shown as "Record Cost") and dividing it by the "Total Cost" of that project to render "Ratio".
    The Total Cost is retrieved from another table.

    Testing scenarios:
    If we exclude Ratio, the whole query import just fine.
    If we filter the query to one project (i.e. "Project A") the ratio field imports fine.
    However, the whole unfiltered query does not with the ratio!

    Other testing scenarios:
    If we use a constant for the denominator AS "1" in Ratio (i.e. recordcost/1) the whole unfiltered query and ratio field imports fine.
    If we use a constant for the numerator AS "1" in Ratio (i.e. 1/totalcost) the whole unfiltered query upon import crashes in Excel.

    This is a mock example of the dataset, the actual query has 50K+ records:

    Project Service Date Record Cost Total Cost Ratio
    A Welding 1/1/2012 $100 $120 83%
    A Plumbing 2/1/2012 $20 $120 17%
    B Welding 1/1/2012 $50 $75 67%
    B Plumbing 2/1/2012 $25 $75 33%
    C Welding 1/1/2012 $40 $61 66%
    C Plumbing 2/1/2012 $21 $61 34%


    Thanks in advance. Al

  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,652
    Is it possible there are records with either Null or 0 in the "Total Cost" field? That would cause a division by zero error that you might not see in Access until you navigated to/beyond that record in the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    How are you retrieving TotalCost from the other table - DLookup or subquery?

    Post query statement and sample of source data, not just the desired output.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    Are any of your denominators (total cost) 0? (I've never tried to link a query to an excel file as the data source but this is my guess for what's going on, some problem with the numbers involved that you can see in the access query but excel can't interpret)

    Have you tried exporting the query to excel and seeing if you get the correct value as opposed to directly linking to an access query?

    I'd also check all your numerators to see if they're 0 either or in your ratio column instead of having a simple division have something like

    iif(isnull([record cost]) or [record cost] = 0, 0, iif(isnull([total cost]) or [total cost] = 0, 0, [record cost]/[total cost]))

  5. #5
    countingguru is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    17
    Yes some projects have total cost "0" values

  6. #6
    countingguru is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    17
    rpeare <<<<<< is a genius !!!! THANK YOU IT WORK !!!

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

Similar Threads

  1. Excel Import field truncation problem (to Access Memo field)
    By jhrBanker in forum Import/Export Data
    Replies: 6
    Last Post: 07-27-2012, 08:52 AM
  2. Replies: 1
    Last Post: 06-27-2012, 07:39 AM
  3. Replies: 7
    Last Post: 05-09-2012, 06:06 AM
  4. Replies: 1
    Last Post: 01-23-2012, 11:44 AM
  5. Calcuated Query for Instock Field
    By emjhay13 in forum Queries
    Replies: 9
    Last Post: 12-03-2011, 10:39 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