Results 1 to 4 of 4
  1. #1
    rbennion is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jun 2017
    Posts
    17

    Filtering a COUNT

    Guys,



    Why am I struggling with this the way I am.

    I have a list of rehab patients. All patients are "referred" however only some "enroll", meaning actually show up. I just need to COUNT the amount that actually enroll (I identify these by if they have an enrollment date or if it's just NULL). Basically, I just need to:

    COUNT(Enrollment_Date)
    FROM General
    WHERE Enrollment_Date IS NOT NULL

    Obviously, this wont work. I have used IIf but I really don't understand it and feel like it's just a work-around. Should I be using a subquery? Should I use Switch? I would love your recommendation. If it is one of these I have just mentioned, please elaborate a little as I rarely use either subquerys or switch (I used to just use CASE but Access queries doesn't allow it).

    Thanks all!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    dont need the IIf .
    make a query, Q1 to pull all EnrollDate not null. or other criteria.
    make Q2 to count the recs in Q1.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Assuming each patient can have only 1 enrollment record, should be doable in 1 query.

    SELECT Count(*) AS CntEnrolled FROM General WHERE NOT Enrollment_Date IS NULL;

    If you want to count by month or year include those values in grouping.

    SELECT Year(Enrollment_Date) AS Yr, Count(*) AS CntEnrolled FROM General WHERE NOT Enrollment_Date IS NULL GROUP BY Year(Enrollment_Date);
    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
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,044
    Hi ,

    I don't see why the expression is not null shouldn' work. I just tried the following in my DB:

    select count(ID) from Customers where ModifiedDate is null : yielded 532 records
    select count(ID) from Customers where ModifiedDate is not null : yielded 2714 records
    select count(ID) from Customers : yielded 3246 records

    This seems OK to me


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

Similar Threads

  1. Replies: 6
    Last Post: 06-20-2017, 08:56 AM
  2. Replies: 1
    Last Post: 03-06-2017, 06:48 AM
  3. Replies: 2
    Last Post: 06-30-2016, 06:38 PM
  4. Replies: 2
    Last Post: 04-15-2014, 01:59 PM
  5. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 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