Hi,
I have a form with a subform and would like the choice I make in the subform to base on the content of two combobox;[Sex] and [SchoolNo] in the Main form. I have already written the code which is working ok.
The problem is that if I want to change the Sex of the student I need to click again on the SchoolNo for the data in the subform to be filtered. I've been able to work around that by putting the same code on the Event procedures for Sex_AfterUpdate and the Form_Current. Like I've said it is working fine but I just wondering if there is an easier way of doing it. Please find the code below:
Thank you for any help or suggestion.
titanl
I have a form with a subform and would like the choice I make in the subform to base on the content of two combobox;[Sex] and [SchoolNo] in the Main form. I have already written the code which is working ok.
The problem is that if I want to change the Sex of the student I need to click again on the SchoolNo for the data in the subform to be filtered. I've been able to work around that by putting the same code on the Event procedures for Sex_AfterUpdate and the Form_Current. Like I've said it is working fine but I just wondering if there is an easier way of doing it. Please find the code below:
Code:
Private Sub SchoolNo_AfterUpdate()
Select Case Level
Case Is = "P"
strQ = "SELECT Events.EventID, Events.EventName, Events.Category FROM Events WHERE Events.Category Like '" & Gender & "*' And CategoryID Between 1 And 2 ORDER BY Events.Category;"
[AthleteTake subform].Form.cmbEventID.RowSource = strQ
Case Is = "P/S"
strQ = "SELECT Events.EventID, Events.EventName, Events.Category FROM Events WHERE Events.Category Like '" & Gender & "*' And CategoryID Between 1 And 3 ORDER BY Events.Category;"
[AthleteTake subform].Form.cmbEventID.RowSource = strQ
Case Is = "S"
strQ = "SELECT Events.EventID, Events.EventName, Events.Category FROM Events WHERE Events.Category Like '" & Gender & "*' And CategoryID Between 2 And 3 ORDER BY Events.Category;"
[AthleteTake subform].Form.cmbEventID.RowSource = strQ
Case Else
strQ = "SELECT Events.EventID, Events.EventName, Events.Category FROM Events WHERE Events.Category Like '" & Gender & "*' And CategoryID Between 4 And 5 ORDER BY Events.Category;"
[AthleteTake subform].Form.cmbEventID.RowSource = strQ
End Select
End Sub
Thank you for any help or suggestion.
titanl