Results 1 to 5 of 5
  1. #1
    maxmaggot is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Location
    Ireland
    Posts
    91

    Value from DSUM with multiple criteria wrong

    I have a DSUM function in a report and I think I almost have it right but I just can't get the syntax exactly right. It keeps returning 0.



    Code:
    =Nz(DSum("[Amount]","Expenses","[Expense Type] =2" & " AND  [InvoiceDate] Between " & DateSerial(Year(Date()),1,1) & " And "  & DateSerial(Year(Date()),12,31)),0)
    All fields exist as spelt and are set to the correct data types.

    Any help from anyone please? Thank you.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,526
    The date values need delimiters:

    http://access.mvps.org/access/general/gen0018.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    maxmaggot is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Location
    Ireland
    Posts
    91
    I've added the delimiters as follows but I'm getting an error message now
    Code:
    =Nz(DSum("[Amount]","Expenses","[Expense Type] =2" & " AND [InvoiceDate] Between #" & DateSerial(Year(Date()),1,1) & "# And #" & DateSerial(Year(Date()),12,31)),0) & "#"

  4. #4
    maxmaggot is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Location
    Ireland
    Posts
    91
    My mistake. fixed now. Put the last delimiter outside the DSUM. Working now with
    Code:
    =Nz(DSum("[Amount]","Expenses","[Expense Type] =2" & " AND [InvoiceDate] Between #" & DateSerial(Year(Date()),1,1) & "# And #" & DateSerial(Year(Date()),12,31) & "#"),0)
    Thanks for your help
    Last edited by maxmaggot; 04-12-2014 at 05:11 PM. Reason: typo

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,526
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Dsum return wrong answer
    By mikichi in forum Access
    Replies: 4
    Last Post: 03-03-2014, 11:17 AM
  2. dsum with criteria Not like 38,39,40,41
    By sdel_nevo in forum Programming
    Replies: 3
    Last Post: 06-13-2013, 03:23 PM
  3. Dsum criteria
    By bdaniel in forum Queries
    Replies: 4
    Last Post: 11-27-2011, 03:41 PM
  4. Dsum criteria problem
    By leonhuynh2006 in forum Queries
    Replies: 3
    Last Post: 10-04-2011, 03:18 AM
  5. How to use a create a DSum with multiple criteria
    By FlyingDisc in forum Reports
    Replies: 1
    Last Post: 01-05-2011, 08:31 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