U
unhinged
G'day,
I have a student details form, fmvqStudent (based on qStudentDetails),
with a tab control. The tab control for attendance shows two combo
boxes: cbxCurrentClassID (Number) and cbxShowPeriod (Date). The former
is bound to qStudentDetails.CurrentClassID.
There is also a subform, sfmtAttendance, which is based on the
tAttendances table and linked by qStudentDetails.StudentID =
tAttendance.StudentID and qStudentDetails.CurrentClassID =
tAttendance.ClassID.
I am trying to have a user select a class from one combo box and have
every related attendance record show on the subform. The footer of the
subform has calculated controls showing the total hours attended, total
hours required and the percentage of attendance. The attendance data is
recorded fortnightly for some classes and monthly for others, so I want
to be able to filter the subform to only display those records matching
the value in cbxShowPeriod.
That part, after much experimentation, now works. Yay me.
What is not working is the value list attaching to cbxShowPeriod. When
I first open the form fmvqStudent and navigate to the Attendance tab, I
have a class displayed in cbxCurrentClassID and the values in
cbxShowPeriod are correct. But I do not see any of the related records
until I click on a command button, cmdShowAllPeriods, which has the
following code:
Me.sfmtAttendance.Form.FilterOn = False
[cbxShowPeriod] = Null
Me.sfmtAttendance.Form.Requery
I'm thinking there's an OnLoad event that needs to happen to show the
related data, but any suggestions on this point are welcome.
However, what I am really worried about is that when I select a
different class from cbxCurrentClassID, the value list populating
cbxShowPeriod becomes a NULL list and the subform recordset does not
update. But if I close the form and re-open it, the cbxShowPeriod value
list is correctly populated with the values from the new value in
cbxCurrentClassID.
Here's the AfterUpdate event code from cbxCurrentClassID:
Me.sfmtAttendance.Form.Requery
[cbxShowPeriod] = Null
Me.cbxShowPeriod.RowSource = "SELECT DISTINCT
tAttendance.WeekCommencingDate FROM qStudentDetails INNER JOIN
tAttendance ON (qStudentDetails.CurrentClassID = tAttendance.ClassID)
AND (qStudentDetails.StudentID = tAttendance.StudentID) WHERE
(((tAttendance.ClassID)=[cbxCurrentClassID]));"
The AfterUpdate event code for cbxShowPeriod is:
Dim strInput As Variant
Dim strFilter As String
' store value selected by user in combo box
strInput = Nz([cbxShowPeriod], 0)
' Build criteria string
strFilter = BuildCriteria("WeekCommencingDate", dbDate, strInput)
Me.sfmtAttendance.Form.Filter = strFilter
Me.sfmtAttendance.Form.FilterOn = True
I'm not sure what else is needed. I know that the system basically
works because of the behaviour described above, but I am really
struggling to get the instant update part working.
Thanks in Advance,
Daniel.
I have a student details form, fmvqStudent (based on qStudentDetails),
with a tab control. The tab control for attendance shows two combo
boxes: cbxCurrentClassID (Number) and cbxShowPeriod (Date). The former
is bound to qStudentDetails.CurrentClassID.
There is also a subform, sfmtAttendance, which is based on the
tAttendances table and linked by qStudentDetails.StudentID =
tAttendance.StudentID and qStudentDetails.CurrentClassID =
tAttendance.ClassID.
I am trying to have a user select a class from one combo box and have
every related attendance record show on the subform. The footer of the
subform has calculated controls showing the total hours attended, total
hours required and the percentage of attendance. The attendance data is
recorded fortnightly for some classes and monthly for others, so I want
to be able to filter the subform to only display those records matching
the value in cbxShowPeriod.
That part, after much experimentation, now works. Yay me.
What is not working is the value list attaching to cbxShowPeriod. When
I first open the form fmvqStudent and navigate to the Attendance tab, I
have a class displayed in cbxCurrentClassID and the values in
cbxShowPeriod are correct. But I do not see any of the related records
until I click on a command button, cmdShowAllPeriods, which has the
following code:
Me.sfmtAttendance.Form.FilterOn = False
[cbxShowPeriod] = Null
Me.sfmtAttendance.Form.Requery
I'm thinking there's an OnLoad event that needs to happen to show the
related data, but any suggestions on this point are welcome.
However, what I am really worried about is that when I select a
different class from cbxCurrentClassID, the value list populating
cbxShowPeriod becomes a NULL list and the subform recordset does not
update. But if I close the form and re-open it, the cbxShowPeriod value
list is correctly populated with the values from the new value in
cbxCurrentClassID.
Here's the AfterUpdate event code from cbxCurrentClassID:
Me.sfmtAttendance.Form.Requery
[cbxShowPeriod] = Null
Me.cbxShowPeriod.RowSource = "SELECT DISTINCT
tAttendance.WeekCommencingDate FROM qStudentDetails INNER JOIN
tAttendance ON (qStudentDetails.CurrentClassID = tAttendance.ClassID)
AND (qStudentDetails.StudentID = tAttendance.StudentID) WHERE
(((tAttendance.ClassID)=[cbxCurrentClassID]));"
The AfterUpdate event code for cbxShowPeriod is:
Dim strInput As Variant
Dim strFilter As String
' store value selected by user in combo box
strInput = Nz([cbxShowPeriod], 0)
' Build criteria string
strFilter = BuildCriteria("WeekCommencingDate", dbDate, strInput)
Me.sfmtAttendance.Form.Filter = strFilter
Me.sfmtAttendance.Form.FilterOn = True
I'm not sure what else is needed. I know that the system basically
works because of the behaviour described above, but I am really
struggling to get the instant update part working.
Thanks in Advance,
Daniel.