Need help please
Have a form with a datasheet sub form. I need to delete all the sub form records if a value on the main form is X. So, for example, if the main-form text box value = 0, I need to delete all the related records in the sub form.
My posted code, set in the main form's current event, and the main form control's change event, does not work; get messg “object or class does not support the set of events”. Have tried other code too, got it working but only one record in the sub form deleted. Need it to delete all related records for the 0 value in the main form.
Hope you can point me in the right direction.
Private Sub Form_Current()
Dim db As DAO.Database
Dim rst2Subform As DAO.Recordset
Set db = CurrentDb
Set rst2Subform = Forms![Occinput]![OccLevel2 Subform].Form.Recordset
Do While Not rst2Subform.EOF
If Me.Assessment.Value = 0 Then
Form![OccLevel2 Subform]!Assessment2.Value = Null