Results 1 to 8 of 8
  1. #1
    aliaslamy2k is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Apr 2020
    Posts
    31

    Dcount with two criteria gives error

    Dear Experts,

    I am trying to count from two different fields with criteria but it gives me an error
    I want to select 2020 from Field Name1 and count if greater than 0 from Field Name2


    Table Name : SUMMARY QAFAM 2020
    Field Name1: RP expiry year


    Field Name2: RP RENEWAL


    I am using this formula but its not working.

    =DCount("SUMMARY QAFAM 2020","[RP expiry year] = '2020'","[RP RENEWAL]>'0'")

    Rgds,
    AB

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Try

    DCount("*", "SUMMARY QAFAM 2020","[RP expiry year] = 2020 And [RP RENEWAL]>0")

    i assume both both fields are numeric rather than text.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    aliaslamy2k is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Apr 2020
    Posts
    31
    Hi pbadly,

    My field was set to "SHORT TEXT" earlier. I changed it to number now. But still i am getting an error.
    Attached Thumbnails Attached Thumbnails RP RENEWAL3.JPG   RP RENEWAL4.JPG   RP RENEWAL5.JPG  

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Looks like the field name is year2.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    aliaslamy2k is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Apr 2020
    Posts
    31
    Hi pbadly,

    I have created new table from scratch with correct DATA TYPES and used the formula. However, it is still giving me an error. I am not sure where i am going wrong.
    Attached Thumbnails Attached Thumbnails RP RENEWAL6.JPG   RP RENEWAL7.JPG   RP RENEWAL8.JPG   RP RENEWAL9.JPG   RP RENEWAL10.JPG  


  6. #6
    aliaslamy2k is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Apr 2020
    Posts
    31
    Hi pbadly,

    Its working now thank you so much for your help.

    =DCount("*","QAFAM2","[RP EXP YEAR] = 2020 AND [RP RENEWAL]>0")

  7. #7
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    FYI, you should NOT use spaces in object names. This includes field names, table names, query names. form names, report names, etc......

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Quote Originally Posted by aliaslamy2k View Post
    Hi pbadly,

    Its working now thank you so much for your help
    Happy to help!
    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. dcount with 2 criteria
    By Nobby2193 in forum Access
    Replies: 2
    Last Post: 02-04-2019, 03:46 AM
  2. dcount criteria
    By markjkubicki in forum Programming
    Replies: 2
    Last Post: 11-26-2018, 03:01 PM
  3. DCOUNT Muliple criteria
    By civl_eng in forum Access
    Replies: 11
    Last Post: 05-03-2018, 12:27 PM
  4. DCount with Multiple Criteria
    By Newbie11 in forum Reports
    Replies: 4
    Last Post: 05-25-2012, 09:04 AM
  5. How do you use DCOUNT for multiple criteria?
    By wwhit in forum Programming
    Replies: 5
    Last Post: 05-15-2012, 11:14 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