Results 1 to 9 of 9
  1. #1
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231

    Dsum with Nz Causes Overflow

    I'm having trouble figuring out the syntax of the dsum while using Nz. Here's what I have so far:



    building_sq_ft = DSum("Nz([ArenaSqFt],0) + Nz([ShedSqFt],0) + Nz([MaintSqFt],0)", "FULL_COMM_BREAKDOWN", "MEMBER_ID=" & [current_id])

    Can anyone see what's wrong with this line? I'm getting a Run Time Error '6' Overflow......

    CementCarver

  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,642
    Never tried to use it that way, but it might work. What data type is building_sq_ft declared as, and what value would you expect to come from the DSum()?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    Building_sq_ft is claimed as an integer. And what I'm expecting is to sum all three fields and udpate the total sq. footage field after any updated has happened on those three fields.

    I then run a recordset .edit and update the total sq. footage field.

    CementCarver

  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,642
    I meant what value? An integer data type can only hold 32k. Might the result be higher than that?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Member_ID is number field?

    I tested, calc works.

    But is bad idea to save aggregate data. Calculate the Sum when needed but don't save to table.
    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.

  6. #6
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    I need to calculate the sum and store the resultant total sq. footage. June 7, are you saying to NOT have a field to store this total and to keep a running total just as a display item in a field? Right now, I store the actual value in a field called BUILDING_TOTAL.

    As for pbaldy, the highest number I'm storing now is 5,475,536, so I think my claiming the variable as an integer is incorrect here.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    What do you mean by a 'running total'?

    Yes, I am suggesting you not save the sum to table. Review http://allenbrowne.com/casu-14.html
    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.

  8. #8
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    I meant by saying "running total" is to calculate the sum of those fields when needed to display the result and not store the actual value in the database.

    It never dawned on me to just calculate this values from within vba code, and not actually have to store the resultant value in the database. Thankx for your help.

    CementCarver

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    Doesn't require VBA code. This calculation can be done with query or in textbox on form/report.
    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.

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

Similar Threads

  1. Overflow
    By Joe8915 in forum Forms
    Replies: 4
    Last Post: 10-28-2012, 05:21 PM
  2. Overflow
    By roar58 in forum Queries
    Replies: 1
    Last Post: 10-02-2012, 10:37 AM
  3. Overflow in Query
    By crcastilla in forum Access
    Replies: 1
    Last Post: 05-20-2012, 12:42 AM
  4. Overflow from Criteria
    By thesmug1 in forum Queries
    Replies: 4
    Last Post: 08-05-2011, 08:26 AM
  5. Overflow Message...?
    By batowl in forum Reports
    Replies: 3
    Last Post: 01-13-2011, 02:58 PM

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