D
Dave Nene
Hi,
I have two tables. On the 1 side is Yr8students and on the many side is
Attendance. Referential Integrity is set.
I have populated the Yr8student table with 30 names and student ids. This
table is linked via its StudentID field to a StudentID field in attendance.
To start off with Attendance is empty.
I have a form which is based on a query. The SQL in this query is :-
SELECT Yr8Students.StudentID, Yr8Students.Firstname, Yr8Students.Lastname,
Attendance.Subject, Attendance.Attended, Attendance.Punctuality,
Attendance.Date, Attendance.StudentID
FROM Yr8Students LEFT JOIN Attendance ON Yr8Students.StudentID =
Attendance.StudentID;
I want to be able to use DAO to populate certain fields in attendance for
each of the 30 student records.
I have used the following code in the On Open event of the form :-
Private Sub Form_Open(Cancel As Integer)
Dim reg As DAO.Recordset
Dim dt As Date
dt = Now
Set db = CurrentDb
Set reg = db.OpenRecordset("Yr8Attending", dbOpenDynaset)
reg.MoveFirst
Do While Not reg.EOF
reg.Edit
reg!Attended = "True"
reg!Subject = "Science"
reg!Date = dt
reg.Update
reg.MoveNext
Loop
Forms!Yr8Attending.Requery
reg.Close
End Sub
The purpose of this is to set the Attendance records for a particular class
and date with all students attending, then for instance the teacher can
just click on particular records to indicate students who are absent.
The code above works but not unexpectedly when run again simply edits the
Attendance records already entered again.
Basically I want to add new attendance records on the many side for
different classes based upon date.
I have tried AddNew without success.
Some of this does appear to depend upon when the record on the Many side is
created. Is it possible to force this to happen.
Any Thoughts ?
Rgds
Dave
This works but what I really want to do is to append the attendance records
with new records based upon a different attendance date
I have two tables. On the 1 side is Yr8students and on the many side is
Attendance. Referential Integrity is set.
I have populated the Yr8student table with 30 names and student ids. This
table is linked via its StudentID field to a StudentID field in attendance.
To start off with Attendance is empty.
I have a form which is based on a query. The SQL in this query is :-
SELECT Yr8Students.StudentID, Yr8Students.Firstname, Yr8Students.Lastname,
Attendance.Subject, Attendance.Attended, Attendance.Punctuality,
Attendance.Date, Attendance.StudentID
FROM Yr8Students LEFT JOIN Attendance ON Yr8Students.StudentID =
Attendance.StudentID;
I want to be able to use DAO to populate certain fields in attendance for
each of the 30 student records.
I have used the following code in the On Open event of the form :-
Private Sub Form_Open(Cancel As Integer)
Dim reg As DAO.Recordset
Dim dt As Date
dt = Now
Set db = CurrentDb
Set reg = db.OpenRecordset("Yr8Attending", dbOpenDynaset)
reg.MoveFirst
Do While Not reg.EOF
reg.Edit
reg!Attended = "True"
reg!Subject = "Science"
reg!Date = dt
reg.Update
reg.MoveNext
Loop
Forms!Yr8Attending.Requery
reg.Close
End Sub
The purpose of this is to set the Attendance records for a particular class
and date with all students attending, then for instance the teacher can
just click on particular records to indicate students who are absent.
The code above works but not unexpectedly when run again simply edits the
Attendance records already entered again.
Basically I want to add new attendance records on the many side for
different classes based upon date.
I have tried AddNew without success.
Some of this does appear to depend upon when the record on the Many side is
created. Is it possible to force this to happen.
Any Thoughts ?
Rgds
Dave
This works but what I really want to do is to append the attendance records
with new records based upon a different attendance date