Results 1 to 7 of 7
  1. #1
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    39

    DSum Like Critiria


    Hi,

    I've got a code that works fine.

    =DSum("[amount]","[qtExpense2015]","[description] = 'Walmart'")

    I was looking for a slight update for something that didn't need to have the exact word but contain the word someplace in the field.

    Something along these lines..... this obviously doesn't work.
    =DSum("[amount]","[qtExpense2015]","[description] = Like '*Gas*'")

    This probably isn't the way to handle it but I was hoping to do a couple fields like this and was wondering if I could avoid the quiery.

    Thank you.

  2. #2
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    39
    Sorry, I should have put this in the Forms area. If anyone can move it that would be great.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Try this
    Something along these lines..... this obviously doesn't work.
    Code:
    =DSum("[amount]","[qtExpense2015]","[description]  Like '*Gas*'")
    I did a test with one of my tables
    Course with the following data:

    CId Coursename
    1 Spanish
    2 English
    3 Chemistry
    4 Physics
    5 Latin
    6 Biology
    7 Botany
    8 History
    9 Political Science
    10 Astronomy
    11 French
    12 Algebra
    13 Geometry


    ?dcount("*","Course","CourseName like '*ry'")
    3

  4. #4
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    39
    Thank you Orange.

    The = in the criteria was what I had wrong! Got it working perfect now!!! I think......

  5. #5
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    39
    One more question.

    How do I write that to include two criteria from the same field?

    =DSum("amount","qtExpense","[description] like '*Gas*'")+DSum("amount","qtExpense","[description] like '*hess*'")
    This works but there must be a simpler way.

    Can I write something simpler then that?

    =DSum("amount","qtExpense","[description] like '*Gas*' Or '*hess*'")

    I'm looking for it to include both criteria but not require both to be in there.

    Thank you.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Try:
    =DSum("amount","qtExpense","[description] like '*Gas*' Or [description] like '*hess*'")

  7. #7
    Dormie is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    39
    Awesome worked. I swear I tried that..... but got it working now. Thank you!

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

Similar Threads

  1. DSum
    By balajigade in forum Queries
    Replies: 1
    Last Post: 04-26-2015, 10:26 AM
  2. Filter Critiria Storage
    By gg80 in forum Forms
    Replies: 2
    Last Post: 10-09-2012, 08:12 AM
  3. Dsum Help?
    By Ragin_roider in forum Queries
    Replies: 5
    Last Post: 03-19-2012, 03:10 PM
  4. Help with Sum and DSum
    By objNoob in forum Reports
    Replies: 5
    Last Post: 12-05-2011, 01:55 AM
  5. How do I use the DSum
    By Ironclaw in forum Access
    Replies: 1
    Last Post: 08-25-2010, 07:35 AM

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