Once you properly normalize the table (and I strongly suggest that you do),
the query will be simple:
Select Student, Attendance, Count(*) As AttandanceCount
From YourTable
Group By Student, Attendance;
This will produce a file similar to:
John, A, 3
John, P, 2
Mary, A, 1
Mary, L, 1
Mary, M/U, 1
Dick, L, 2
An easy alternative if you want each attendance type listed across the top
is to use the crosstab query wizard to build the query and then you'll end
up with
Student, A, P, L, [M/U]
John, 3,2,0,0
Mary, 1,0,1,0
Dick, 0,0,2,0
Your table design reflects what you would have done had you built the
application with Excel. But, tables with this design are handled poorly by
relational databases and you are going to HATE Access and never know why.
No matter how far your design has progressed, I suggest backing up and
fixing the table definitions. 2400 records is nothing to a relational
database. Many Access databases operate easily with tables containing
millions of rows. In fact, you can reduce the number of rows substantially
if you store only exception records. That means that a student does NOT
have a row in the table when he was present. He only has a row when there
is some exception activity to report. This might be a little tricky for you
because it will involve working with a table of dates in many of your
queries when you need all students to appear even though they have no
exceptional activity.
If you don't think you understand how to work with the sparse table, you can
build a query that appends a row for each person in the class for a
particular date. Place this code in a button on a form and run it
immediately before you want to enter the exceptions for that day. Don't add
these records ahead of time because you don't know what your class roster
will be for every future day. It can easily change as the semester
progresses. Then the subform should show only the records for a particular
date and you can modify the ones that have exceptions.
f2rox said:
ChrisM,
Once the query is set up i will not have to add any more fields. But,
there
are 80 class dates, and 30 students. So with your suggested design, I
would
have 2400 records. Also, my tables have some complicated relationships
that
would be messed up.
Any ideas?
But, assuming I was able to successfully use your design, how would I
phrase
the expression to calculate number of absences, latenesses, etc.