Question : How to trigger Form events?

If I use the code below (button code) to delete a record in a subform data sheet, then the code I have in Form - On Delete Event doesn't get triggered. How can I make Form events trigger while using the code below?

Private Sub cmdSubDeleteRecord_Click()

On Error GoTo Err_MyProc

   Me.sub_frmSessionAttendance.Form.Recordset.Delete

Exit_MyProc:
        'Deassign all objects.
       
        Exit Sub

Err_MyProc:
        'Error handler here
        Select Case (Err.Number)
            Case 3021
                MsgBox "No record is selected."
            Case Else
               MsgBox (Err.Description)
        End Select
   
        Resume Exit_MyProc
End Sub

Answer : How to trigger Form events?

I didn't catch that before. Try:

DoCmd.RunCommand acCmdDeleteRecord

in place of your delete statment.

JimD.

Random Solutions  
 
programming4us programming4us