Results 1 to 9 of 9
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    DSum with multiple criteria

    I need to get a sum from a query using 3 criteria. Using only one works great. =Nz(DSum("LeaveHours","qrySchLeaveDates","Employee sID=" & [cboEmployee]))


    I need also to qualify it with [WorkLeaveID]=5 and also with [Finalized]=False. I'm not sure how to go about doing this. I tried this. =Nz(DSum("LeaveHours","qrySchLeaveDates","Employee sID=" & [cboEmployee] and WorkLeave=5 and Finalized=False))
    It gave me nothing. How do I do this?

  2. #2
    xps35's Avatar
    xps35 is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    Try
    "Employee sID=" & [cboEmployee] & " and WorkLeave=5 and Finalized=False"

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I get #ERROR

  4. #4
    xps35's Avatar
    xps35 is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    229
    Is WorkLeave numeric and Finalized boolean (yes/no)?

  5. #5
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Correct to both

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,903
    You did include the rest of the DSum and not just the code supplied, which was only meant to replace the criteria?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    That was everything I did. I don't know of anything else to do.

  8. #8
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Figured it out:
    =Nz(DSum("LeaveHours","qrySchLeaveDates","Employee sID=" & [cboEmployee] & " and WorkLeaveID=5" & " and Finalized=False"))

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,903
    So all you needed in post #5 was workleaveid and not workleave ?
    It is up to you to get the names correct all that was offered was the correct syntax.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Dsum w/Multiple Criteria
    By DMcTegra in forum Queries
    Replies: 5
    Last Post: 06-15-2021, 10:56 AM
  2. DSUM Multiple Criteria
    By justdone in forum Queries
    Replies: 3
    Last Post: 10-08-2020, 07:41 PM
  3. Help! Stuck on DSUM with multiple criteria...
    By tbraswell in forum Access
    Replies: 2
    Last Post: 01-03-2019, 10:13 AM
  4. DSUM with multiple criteria
    By Bkper087 in forum Access
    Replies: 4
    Last Post: 02-13-2017, 10:19 PM
  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

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