Results 1 to 4 of 4
  1. #1
    adrianf44 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2018
    Posts
    11

    DCount using OR for multiple critera

    I'm trying to obtain a count from my Assets table with any EquipmentName that equals 5570, 5580, or 650 AND whether it is Checked In or Checked Out. Right now I'm using

    =DCount("[ID]","tblAssets","[EquipmentName] Like '5570' or [EquipmentName] Like '5580' or [EquipmentName] Like '650' and [Status] Like 'Checked Out'")

    It gives me a number but it is not accurate and I'm not sure what it is calculating

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    Only use Like where you have wildcards.
    Replace each with =.
    Also put brackets around the three EquipmentName items so Access treats them as a group
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    adrianf44 is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Apr 2018
    Posts
    11
    That absolutely did the trick. Thank you!

  4. #4
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    As an alternative that might be easier to read you could use the "oft forgotten" IN() clause;

    Code:
    =DCount("[ID]","tblAssets","[EquipmentName] IN('5570' ,'5580' ,'650') AND [Status] Like 'Checked Out'")
    Handy if you wanted to build a dynamic In() clause maybe from a select list box, then return a count.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. DSum with Multiple Critera in a Query
    By flamingphoenix in forum Queries
    Replies: 1
    Last Post: 11-11-2014, 11:04 AM
  2. Replies: 3
    Last Post: 08-26-2014, 03:49 PM
  3. How do you use DCOUNT for multiple criteria?
    By wwhit in forum Programming
    Replies: 5
    Last Post: 05-15-2012, 11:14 AM
  4. multiple seach critera
    By dirtbiker1824 in forum Queries
    Replies: 1
    Last Post: 03-29-2011, 01:17 PM
  5. Query that would search multiple critera and delete
    By justinwright in forum Queries
    Replies: 2
    Last Post: 08-25-2010, 10:05 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