Hello,
I have a main form (frmClass) that contains a subform (sfrmMaterials).
The materials subform populates when a user chooses a course from a course combobox. The fields that populate in the subform are Instrument, Cost, Vendor and a checkbox (chkSelected).
What I would like to do is have the user be able to check the checkbox next to the instruments they would like to use and have the sum of the total cost of instruments checked multiplied by the estimated number of students (txtEstStudents on the main form) display in a textbox on the main form.
To note, the checkbox in the continuous subform is bound to a field (Selected) in the materials table.
I was able to get this to work with one minor issue. The event doesn't happen until the user selects a second checkbox. For example, if a user selects a course (say there is only 1 student) and it contains 2 instruments (a book ($10) and pad of paper($1)), and the user selects the book, the txtbox with the total cost for materials will not change until the user checks the pad of paper. At this point, the total will be $10 and the pad of paper will not be added.
Here is the code that I used -
I have tried this code on the AfterUpdate and Click events as well with the same result.
Any help getting the event to work on the first check would be appreciated.
Thanks.
I have a main form (frmClass) that contains a subform (sfrmMaterials).
The materials subform populates when a user chooses a course from a course combobox. The fields that populate in the subform are Instrument, Cost, Vendor and a checkbox (chkSelected).
What I would like to do is have the user be able to check the checkbox next to the instruments they would like to use and have the sum of the total cost of instruments checked multiplied by the estimated number of students (txtEstStudents on the main form) display in a textbox on the main form.
To note, the checkbox in the continuous subform is bound to a field (Selected) in the materials table.
I was able to get this to work with one minor issue. The event doesn't happen until the user selects a second checkbox. For example, if a user selects a course (say there is only 1 student) and it contains 2 instruments (a book ($10) and pad of paper($1)), and the user selects the book, the txtbox with the total cost for materials will not change until the user checks the pad of paper. At this point, the total will be $10 and the pad of paper will not be added.
Here is the code that I used -
Code:
Private Sub chkSelected_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Forms!frmClass!txtMaterialsFee = DSum("Cost", "qryMaterials", "CourseID = " & [Forms]![frmClass]![cboCourseList] & " AND " & "Selected = -1") * Forms!frmClass!txtEstStudents
End Sub
I have tried this code on the AfterUpdate and Click events as well with the same result.
Any help getting the event to work on the first check would be appreciated.
Thanks.