Results 1 to 3 of 3
  1. #1
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45

    summing values


    I have this query that works fine ... as a query. However, I need to use it in a report to get a value for a single text box. And, since I need to do this for each month, I can't see making 12 sub-reports just to get a sum. I was trying to use DSUM (example provided) but that's not working - it provides the sum of everything; it doesn't provide the sum for just January.

    Suggestions?

    Code:
    SELECT Sum(tblTrackingDelivery.poValue) AS SumOfpoValue, Month([payVendorNLTDate])=1 AS January
    FROM tblTrackingDelivery
    GROUP BY Month([payVendorNLTDate])=1
    HAVING (((Month([payVendorNLTDate])=1)=True));
    Code:
    Me.txtJanPayOut.Value = Nz(DSum("poValue", "tblTrackingDelivery", "Month(payVendorNLTDate) = 1", 0))

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Looks like a closing parenthesis might be in the wrong place.
    You have
    Code:
    Me.txtJanPayOut.Value = Nz(DSum("poValue", "tblTrackingDelivery", "Month(payVendorNLTDate) = 1", 0))
    Try
    Code:
    Me.txtJanPayOut = Nz(DSum("poValue", "tblTrackingDelivery", "Month(payVendorNLTDate) = 1"), 0)
    Don't need ".Value"..... it is the default property. Doesn't hurt - just extra typing.



    Edit......Does "payVendorNLTDate" have a year component?. Might have to add the year to limit the DSum to a specific year.



    ---------------------------
    Without NZ(): DSum("poValue", "tblTrackingDelivery", "Month(payVendorNLTDate) = 1")

    Adding NZ(): NZ(DSum("poValue", "tblTrackingDelivery", "Month(payVendorNLTDate) = 1"),0)

  3. #3
    Dave D is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Jun 2014
    Posts
    45
    Thank you, ssanfu. Your change worked.

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

Similar Threads

  1. Summing Values Based On Other Field
    By JeffGeorge in forum Queries
    Replies: 9
    Last Post: 08-13-2013, 02:00 PM
  2. Summing Values from 2 Tables
    By bryan0 in forum Queries
    Replies: 2
    Last Post: 10-26-2012, 02:45 PM
  3. Summing all values from a certain date
    By juliorevka in forum Access
    Replies: 3
    Last Post: 02-13-2012, 10:02 AM
  4. Issue summing two field values
    By w2vijay in forum Reports
    Replies: 4
    Last Post: 02-10-2010, 01:53 AM
  5. summing values associated with date ranges
    By wdemilly in forum Reports
    Replies: 0
    Last Post: 07-17-2009, 01:53 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