Hello, i have difficulty to produce proper code on an AfterUpate event
In my Db in order to keep Attendance of athletes i have a main form called Fr_CourseSessions
it has subforms to select Academic year Tennis Cource, Instructor etc
All is working except: to make easier to track attendance i have inserted on that form, a subform "Frmsub_CourseAttendances", set to continuous, having as source
and what i am after is
a) Opening my main form "Fr_CourseSessions", and selecting year from cboGotoYear, (eg 2021/22), then selecting course from cboGotoCourse,
then in my subform, Frmsub_CourseAttendances which has a txtDate, typing eg 1/5/2022 (or 01/05/2022 a date with records) hit enter,
if attendances are already recorded for that date, these will show in the form, so i can check Attendance (this is working )
or if not, clicking the Add Athletes button , i would like to add all Athletes in that course (currently marked as Active in Tbl_Athletes) so if someone is/was absent, to uncheck Attended
vba behind Add Athletes button is
which gives errors and does not produce the list of Athletes currently in that Course
Could you please help me?
In my Db in order to keep Attendance of athletes i have a main form called Fr_CourseSessions
it has subforms to select Academic year Tennis Cource, Instructor etc
All is working except: to make easier to track attendance i have inserted on that form, a subform "Frmsub_CourseAttendances", set to continuous, having as source
Code:
PARAMETERS [Forms]![Fr_CourseSessions]![cboGoToCourse] Long, [Forms]![Fr_CourseSessions]![Frmsub_CourseAttendances].[Form]![txtDate] DateTime;
SELECT Tbl_CourseAttendances.courseID, Tbl_CourseAttendances.CourseDate, Tbl_CourseAttendances.athleteID, Tbl_CourseAttendances.Attended
FROM Tbl_CourseAttendances INNER JOIN Tbl_Athletes ON Tbl_CourseAttendances.athleteID = Tbl_Athletes.athleteID
WHERE (((Tbl_CourseAttendances.courseID)=[Forms]![Fr_CourseSessions]![cboGoToCourse]) AND ((Tbl_CourseAttendances.CourseDate)=[Forms]![Fr_CourseSessions]![Frmsub_CourseAttendances].[Form]![txtDate]))
ORDER BY Tbl_Athletes.aSurname, Tbl_Athletes.aName;
and what i am after is
a) Opening my main form "Fr_CourseSessions", and selecting year from cboGotoYear, (eg 2021/22), then selecting course from cboGotoCourse,
then in my subform, Frmsub_CourseAttendances which has a txtDate, typing eg 1/5/2022 (or 01/05/2022 a date with records) hit enter,
if attendances are already recorded for that date, these will show in the form, so i can check Attendance (this is working )
or if not, clicking the Add Athletes button , i would like to add all Athletes in that course (currently marked as Active in Tbl_Athletes) so if someone is/was absent, to uncheck Attended
vba behind Add Athletes button is
Code:
Private Sub Add_Athletes_Click()
Dim dbs As DAO.Database
Dim strSQL As String
If Not IsNull(Me.txtDate) Then
strSQL = "INSERT INTO Tbl_CourseAttendances(athleteID,CourseDate) " & _
"SELECT athleteID, #" & Format(Me.txtDate, "yyyy-mm-dd") & "# " & _
"FROM Tbl_Athletes WHERE aStatus=0;"
CurrentDb.Execute strSQL, dbFailOnError
Me.Requery
End If
End Sub
which gives errors and does not produce the list of Athletes currently in that Course
Could you please help me?