HI folks
I have a table where student attendance history is recorded.
In order to update a student attendance for today, I would like to select their latest record (from yesterday or Friday if today happens to be a Monday) and assign the same attendance status that they had the last time that the role was taken.
So I have the following query.
SELECT Tbl_SchoolAttendance.ClassID, Tbl_SchoolAttendance.StudentID, Tbl_SchoolAttendance.AttendDate, Tbl_SchoolAttendance.SchoolAM, Tbl_SchoolAttendance.SchoolPM, Tbl_SchoolAttendance.AttendDate AS LastDt
FROM Tbl_SchoolAttendance
WHERE Tbl_SchoolAttendance.AttendDate =
(SELECT MAX(Tbl_SchoolAttendance.AttendDate) FROM Tbl_SchoolAttendance as LastDate)
ORDER BY Tbl_SchoolAttendance.ClassID, Tbl_SchoolAttendance.StudentID, Tbl_SchoolAttendance.AttendDate;
The problem is that this returns ALL the attendance records.
I only want the records that have the highest AttendDate.
I have also tries to use the TOP function as in
(SELECT TOP 1 (Tbl_SchoolAttendance.AttendDate)
but this also returns ALL records.
Any ideas?
(Access 2010)
I have a table where student attendance history is recorded.
In order to update a student attendance for today, I would like to select their latest record (from yesterday or Friday if today happens to be a Monday) and assign the same attendance status that they had the last time that the role was taken.
So I have the following query.
SELECT Tbl_SchoolAttendance.ClassID, Tbl_SchoolAttendance.StudentID, Tbl_SchoolAttendance.AttendDate, Tbl_SchoolAttendance.SchoolAM, Tbl_SchoolAttendance.SchoolPM, Tbl_SchoolAttendance.AttendDate AS LastDt
FROM Tbl_SchoolAttendance
WHERE Tbl_SchoolAttendance.AttendDate =
(SELECT MAX(Tbl_SchoolAttendance.AttendDate) FROM Tbl_SchoolAttendance as LastDate)
ORDER BY Tbl_SchoolAttendance.ClassID, Tbl_SchoolAttendance.StudentID, Tbl_SchoolAttendance.AttendDate;
The problem is that this returns ALL the attendance records.
I only want the records that have the highest AttendDate.
I have also tries to use the TOP function as in
(SELECT TOP 1 (Tbl_SchoolAttendance.AttendDate)
but this also returns ALL records.
Any ideas?
(Access 2010)