Results 1 to 2 of 2
  1. #1
    Ank_db is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2015
    Location
    India
    Posts
    1

    Use the Date as a criteria in Dsum function

    have to generate a rolling sum or Cumulative sum of the OIL field for each WELLNMBR as per its MONTH value.
    The query used is
    Code:
    SELECT tblProductionData.WELLNMBR, tblProductionData.[Month], tblProductionData.DAYS, tblProductionData.OIL, tblProductionData.GAS, tblProductionData.WATER, DSum("[OIL]","tblProductionData","WELLNMBR=" & "'" & [WELLNMBR] & "'" & "AND MONTH <=" & "#" & [MONTH] & "#") AS Expr2
    Code:
    FROM tblProductionData;



    In the result the sum changes after every year, not after a month. I would like to know the reason for this strange behavior and the method to obtain the rolling sum in every month.
    Incorrect result
    Click image for larger version. 

Name:	NFBRm.png 
Views:	14 
Size:	24.1 KB 
ID:	19368

    Correct result
    Click image for larger version. 

Name:	U8I9r.png 
Views:	14 
Size:	23.7 KB 
ID:	19369


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Try including month and year in the aggregate criteria.
    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. Dsum Function
    By LOIZOS in forum Forms
    Replies: 10
    Last Post: 03-20-2014, 10:05 AM
  2. DSum Function
    By azhar2006 in forum Forms
    Replies: 7
    Last Post: 12-08-2013, 05:07 PM
  3. Dsum() Function
    By rkalapura in forum Queries
    Replies: 2
    Last Post: 10-24-2012, 05:58 PM
  4. Dsum() function
    By rkalapura in forum Forms
    Replies: 3
    Last Post: 10-10-2012, 10:06 PM
  5. DSUM with date criteria from form
    By krutoigoga in forum Reports
    Replies: 4
    Last Post: 07-28-2010, 01:32 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