Results 1 to 9 of 9
  1. #1
    cbarnett is offline Novice
    Windows 10 Access 2019
    Join Date
    Jun 2023
    Posts
    3

    Reporting a count of number of records that meet the criteria

    Hi,

    I would like to report a count of the number of students who meet certain criteria.



    e.g.
    I have a table with the following

    Student Name
    Class
    SEND
    IBP
    PPI


    I've grouped them into Classes but now would like to report how many students are PPI (at the moment it is filled with either a 1 for yes or 0 for no) or have an IBP (either a 2 for yes or 0 for no.

    Can I report a count as to how many 1's there are?

    thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Use DCount() ?
    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
    cbarnett is offline Novice
    Windows 10 Access 2019
    Join Date
    Jun 2023
    Posts
    3
    Thanks - unfortunately, it's just giving me an error message. I'm not sure about what to put as the domain.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    unfortunately we are not clairvoyant - suggest provide the code you have created and the detail of the error message.

    Your original post is unclear - you say

    PPI (at the moment it is filled with either a 1 for yes or 0 for no) or have an IBP (either a 2 for yes or 0 for no.


    but you want

    Can I report a count as to how many 1's there are?
    so what is the relevance for this?
    IBP (either a 2 for yes or 0 for no.
    since you want 1's why include IBP which does not have any 1's?

  5. #5
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    I'd say you should change the PPI and IBT to be both Yes\No fields (you can make them to display a check-box if you want) then in a totals query you can group by Class and sum the two fields using PPI_Students:ABS([PPI]),IBP_Students:ABS([IBP]).
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Not necessary for field to be Yes/No type to do group and sum or count.

    There are arguments against use of Yes/No fields. http://allenbrowne.com/NoYesNo.html
    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.

  7. #7
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    I am aware of that article but for most cases the yes\no fields are working OK (when used as intended with default property set). And what Allen doesn't mention is that they do have an advantage over the number fields in that they come with built-in validation (they can only take true or false or -1 and 0) while for a number field you will have to build that yourself (the OP mentions 2 or True in IBP)...

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    (the OP mentions 2 or True in IBP)
    actually, OP said

    either a 2 for yes or 0 for no.

    The issue I have with yes/no fields is you cannot store a null - you can get the situation where you want 'don't know' as an option, so using a number (I tend to use byte) is a way round that,

  9. #9
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    True=Yes?
    And yes, there is the rare case when you need a Null but for most cases the Yes\No alternatives are enough. To dismiss the usage of the entire data type for very few specific reasons is my my opinion a bit excessive, but that's just me...

    The issue I see in this particular case is trying to add those values; for IBT the OP used 2 to mean yes (or True), maybe for a third field in the future he would use 3 for yes. So you will have replace a simple sum with a count where IBT<>0 or similar plus having to enforce at the table\form level the proper value for each field (so PPI only takes 1 or 0, IBT takes 2 or 0 and so on).

    Anyway the OP seems to be busy at the moment so we'll see if what comes back if anything.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Replies: 5
    Last Post: 04-23-2015, 10:23 AM
  2. Replies: 1
    Last Post: 03-02-2014, 03:25 PM
  3. Only show records that meet criteria
    By RussH in forum Reports
    Replies: 9
    Last Post: 04-10-2013, 05:25 AM
  4. Query for records that do not meet criteria
    By survivo01 in forum Queries
    Replies: 3
    Last Post: 12-16-2012, 05:45 PM
  5. Summing when no records meet criteria
    By clew3 in forum Queries
    Replies: 6
    Last Post: 11-05-2012, 11:37 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