Results 1 to 12 of 12
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    246

    Count number of student in specific school year

    I need to count number of students in a specific grade in a specific school year (previous or current).
    Note that some of the students left school. In this case the field: DateDeparted is not Null and some students are still in the school with DateDeparted is Null.



    Example:
    I want to count students in grade six for school year 2021. If the student is still at school he will be now in grade nine and field DateDeparted is Null, while if he left school after the year 2021 the field DateDeparted will be: Is Not Null.

    Any ideas?

    Khalil

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,980
    Then date does not come into it, does it?
    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
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    246
    Hi,
    I Think no.
    What criteria should I use?

    Khalil

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,728
    How about providing sample data in your table(s) and any queries you have tried?

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,980
    Quote Originally Posted by Khalil Handal View Post
    Hi,
    I Think no.
    What criteria should I use?

    Khalil
    However you define your school year?
    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

  6. #6
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    246
    Hi,
    I defined my school year and I am doing some progress. I will keep all of you posted.
    Thank you

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,980
    If you havce a field that actually defines the school year and perhaps term, like 2021 and 1, then just look for that field being 2021. If you wanted just one term then include that as criteria.
    If you group by those to fields then you'd see all the pupils in that year by term.

    It all depends on how you the developer have define the school year. Some might just use start and end dates, so you would search between those dates.

    At the end of the day, the structure of you DB defines exactly how you would search. From your first post I believe the leaving date does not come into it. If someone leave mid term, they were still in the school in that year?
    So YOU have to be absolutely specific as to what you want.
    Last edited by Welshgasman; 04-27-2024 at 05:01 AM.
    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

  8. #8
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    246
    Hi,
    The school year is actually defined as 2020-2021 and can be selected from a combo box.
    I Added a field CurrentStudent a Yes/No field for table Enrollments which shows the records for all school years for all students and I used that field as criteria (True) to get my results.

    Khalil

  9. #9
    Join Date
    Apr 2017
    Posts
    1,686
    [QUOTE=Khalil Handal;524069]...
    The school year is actually defined as 2020-2021 and can be selected from a combo box.
    I Added a field CurrentStudent a Yes/No field for table Enrollments which shows the records for all school years for all students and I used that field as criteria (True) to get my results.
    /QUOTE]

    No info about your table structures provided jet, so I can only quess.
    Based on your post, you have a table for enrollments with structure like:
    tblEnrollments: EnrollemntID, StudentID, ShoolYear1, SchoolYear2, ..., ShoolYearN, where the SchoolYear# fields are true, when the student was enlisted for this school year, and False or empty, when the student wasn't enlisted. When this is so, then you are on your way into world of hurt for as many years as you use this DB!

    Instead replace the enrollments table with one like:
    tblEnrollments: EnrollmentID, StudentID, SchoolYear, Grade, ...
    For every school year the student is enlisted, there will be a record in tblEnrollments. When the student wasn't enlisted for specific school year, there will be no record for this student in tblEnrollments.
    Having the Grade info in same table allows to keep the info compact eand easily accessible.

    I assume you have also tables where all students are registered and any personal info about them is stored, like
    tblStudents: StudentID, ForName, LastName, ...
    And a table where school years are registered (and is used as source for combo you mentioned), like
    tblSchoolYears: SchoolYear


    With structure like this, your query will be like:
    Code:
    SELECT enr.Grade, Count(enr.StudentID) As StudentsCnt
    FROM tblEnrollments enr
    WHERE enr.SchoolYear = YourSchoolYearComboValue
    Group By enr.Grade
    To get a list of all students in specific grade in specific school year, you use a query like:
    Code:
    SELECT stu.ForeName, stu.LastName, ...
    FROM tblEnrollments enr Inner Join tblStudents stu ON stu.StudentID = enr.StudentID
    WHERE enr.SchoolYear = YourSchoolYearComboValue AND enr.Grade = YourGradeComboValue
    Etc.

  10. #10
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    246
    Hi,
    tblEnrollments: EnrollemntID, StudentID, ShoolYear1, SchoolYear2, ..., ShoolYearN, where the SchoolYear# fields are true, when the student was enlisted for this school year, and False or empty, when the student wasn't enlisted.
    Yes: A student might be enrolled in a school year but not in a different school year.
    To be more clear in relation to the above quote about enrollments, I have a separate table for school years: tblSchoolYears with pkSchoolYears, SchoolYears fields only. In the enrollmwents i have fkSchoolYears field. The same thing also goes for the grade levels. I do also have a table tblStudents for names of students and other related information.
    I will try to apply the above suggested queries and see were it lead me.
    Thank you

  11. #11
    Join Date
    Apr 2017
    Posts
    1,686
    Quote Originally Posted by Khalil Handal View Post
    Yes: A student might be enrolled in a school year but not in a different school year.
    To be more clear in relation to the above quote about enrollments, I have a separate table for school years: tblSchoolYears with pkSchoolYears, SchoolYears fields only. In the enrollmwents i have fkSchoolYears field. The same thing also goes for the grade levels. I do also have a table tblStudents for names of students and other related information.
    I will try to apply the above suggested queries and see were it lead me.
    I think you didn't read my post properly. The table structure where for different school years are different columns doesn't work well (really, this structure works very badly). A couple of reasons on fly:
    I can think about 2 ways to count students for certain year with your current design.
    a) You have to check for every school year column, is it the asked one or not. When yes, you count it, otherwise you ignore it. When the number of school years in your db, increases, the formula to calculate the count in this way will grow too, and very soon will be extremly slow one;
    b) You have to create a procedure, which creates a query string for school year you want students to be counted, and tyhen runs it.
    With either of ways, you have to redesign the query or procedure whenever you add a new school year into your DB. And redesign the enrollments table, the form where you register enrollments, and probably all other tables, queries, and forms which are in any way using enrollments data.

    With alternative design I advised, you can avoid all this hassle!

  12. #12
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    246
    Hi,
    Instead replace the enrollments table with one like:
    tblEnrollments: EnrollmentID, StudentID, SchoolYear, Grade, ...
    I have my table of enrollments as you suggested and I build a query based on it with other necessary tables having a criteria of:
    Like [Forms]![frmStatistics]![cboSchoolYear]
    for selecting the require school year.
    I am getting the totals I need.

    Thank you

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

Similar Threads

  1. Replies: 17
    Last Post: 09-12-2020, 01:28 AM
  2. Replies: 1
    Last Post: 05-13-2015, 03:29 AM
  3. Replies: 5
    Last Post: 12-17-2014, 09:51 PM
  4. Count of specific number
    By samirmehta19 in forum Access
    Replies: 3
    Last Post: 05-20-2013, 02:29 PM
  5. Replies: 2
    Last Post: 04-04-2012, 09:07 PM

Tags for this Thread

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