Results 1 to 4 of 4
  1. #1
    Ganymede is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Dec 2011
    Posts
    116

    DCount w/ Multiple Criteria

    There has been a lot written on this subject but I can't seem to find the solution.



    Desired result: I am writing a dcount in a form textbox that will count the number of records in which the "Status" column = "Pending Paralegal Filing", the "Appeal Deadline" column reflects today's date, and the "Designated Paralegal" = the same value in a form control. Here is my code.

    Code:
    =DCount("[Status]","CostReportAppealsParalegalWindowQ","[Status]= '" & "Pending Paralegal Filing" & "' And [Appeal Deadline]= #" & Format(Date(),"mm/dd/yyyy") & "#" And "[Designated Paralegal] = '" & [Forms]![Login]![cboUser].[Column](3) & "'")
    Based on the result I am getting, I think it is counting the number of times each of those criteria appear in each of those columns and adding the result, as opposed to counting the number of records in which each of those criteria are present. Is there another way to achieve the result I am seeking?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Always put the criteria into a string variable and debug.print it until you get it correct. Then just use that in your function.

    Here is my attempt, as I do not have the data to do just that.
    Code:
    =DCount("[Status]","CostReportAppealsParalegalWindowQ","[Status]= 'Pending Paralegal Filing'  And [Appeal Deadline]= #" & Format(Date(),"mm/dd/yyyy") & "# And [Designated Paralegal] = '" & [Forms]![Login]![cboUser].[Column](3) & "'")
    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

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Or this:

    Code:
    =DCount("*","CostReportAppealsParalegalWindowQ","[Status]= 'Pending Paralegal Filing' And [Appeal Deadline]=Date() And [Designated Paralegal] = '" & [Forms]![Login]![cboUser].Column(3) & "'")
    I presume column 3 of combobox has user name but really should be using user ID instead for filter criteria.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Ganymede is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Dec 2011
    Posts
    116
    Thank you, Both! Resolved!

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

Similar Threads

  1. Dcount function with multiple criteria
    By eusebio in forum Forms
    Replies: 1
    Last Post: 11-23-2018, 04:45 PM
  2. DCount Multiple Criteria Not Working
    By seantnash in forum Queries
    Replies: 6
    Last Post: 08-19-2016, 02:40 PM
  3. Replies: 2
    Last Post: 02-26-2014, 05:06 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