Results 1 to 5 of 5
  1. #1
    Bkper087 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    May 2014
    Posts
    81

    DSUM with multiple criteria

    I'm having issues with the DSUM function. I'm trying to use multiple criteria. Not sure what is happening, but its returning a number way too large. The database is a budget tracking tool. I have one query that includes all categories of expenses separated using check box indicators for budgeted, forecasted expenses, and actual expenses. I am trying to use DSUM on a form to show the total amount spent vs budgeted based on a combo box which the user selects the expense category from. In the expression below, I am trying to get the budgeted amount. All criteria should be numeric values. Any idea what might be wrong?



    =DSum("[ExpenseTotal]","[qryExpense_Printing]","[EventIDfk]=" & [EventIDfk] And "[Budget]=" & [Budget] And "[CategoryIDfk]=" & [CategoryIDfk])

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    =DSum("[ExpenseTotal]","[qryExpense_Printing]","[EventIDfk]=" & [EventIDfk] & " And [Budget]=" & [Budget] & " And [CategoryIDfk]=" & [CategoryIDfk])

  3. #3
    NTC is offline VIP
    Windows 10 Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    as a111 post displays - the DSUM multi criteria scenario becomes very syntax sensitive. An alternative approach is to use a query instead, save it with a name. And then use a DLookUp to call in the value of the Query. Besides avoiding the nasty syntax one can run that query standalone in order to test and refine it.

  4. #4
    Bkper087 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    May 2014
    Posts
    81
    I tried using the expression aytee111 wrote, but got a #Name error. I'm just going to use query's to reference.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So did you try debugging the expression?

    Where are the values "EventIDfk", "Budget" and "CategoryIDfk" coming from? If they are from controls on a form, I would use "Me." and the control name
    If the control name is "EventIDfk", then I would use Me.EventIDfk.

    Start by using one criteria.
    "EventIDfk" should be a number, so no delimiters needed
    Code:
    =DSum("[ExpenseTotal]","[qryExpense_Printing]","[EventIDfk]=" & Me.EventIDfk)
    If this returns a value, add another criteria.
    Code:
    =DSum("[ExpenseTotal]","[qryExpense_Printing]","[EventIDfk]=" & Me.EventIDfk & " And [Budget]=" & Me.Budget )
    If this returns a value, add another criteria.
    Code:
    =DSum("[ExpenseTotal]","[qryExpense_Printing]","[EventIDfk]=" & Me.EventIDfk & " And [Budget]=" & Me.Budget & " And  [CategoryIDfk]=" & Me.CategoryIDfk)
    If, at any stage there is an error, fix it, then continue.

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

Similar Threads

  1. DSum with multiple criteria not resetting
    By ms13103 in forum Queries
    Replies: 3
    Last Post: 02-04-2016, 09:34 AM
  2. Help me ! using Dsum with criteria day
    By dahota in forum Forms
    Replies: 4
    Last Post: 06-25-2015, 11:05 AM
  3. Value from DSUM with multiple criteria wrong
    By maxmaggot in forum Reports
    Replies: 4
    Last Post: 04-12-2014, 05:21 PM
  4. 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
  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