K
Kathy R.
I have a form/subform (frmAttendance/sfrAttendee) with a delete record
button on the main form. If my cursor is in a field on the subform, the
delete button deletes the record in the subform. I want it to delete
the record on the main form.
Could you please take a look at this code and tell me what I'm doing
wrong? Thanks!
Kathy R.
Private Sub cmdDelete_Click()
On Error GoTo cmdDelete_Click_Err
On Error Resume Next
DoCmd.GoToControl Screen.PreviousControl.Name
Err.Clear
If (Not Form.NewRecord) Then
DoCmd.RunCommand acCmdDeleteRecord
End If
If (Form.NewRecord And Not Form.Dirty) Then
Beep
End If
If (Form.NewRecord And Form.Dirty) Then
DoCmd.RunCommand acCmdUndo
End If
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
cmdDelete_Click_Exit:
Exit Sub
cmdDelete_Click_Err:
MsgBox Error$
Resume cmdDelete_Click_Exit
End Sub
button on the main form. If my cursor is in a field on the subform, the
delete button deletes the record in the subform. I want it to delete
the record on the main form.
Could you please take a look at this code and tell me what I'm doing
wrong? Thanks!
Kathy R.
Private Sub cmdDelete_Click()
On Error GoTo cmdDelete_Click_Err
On Error Resume Next
DoCmd.GoToControl Screen.PreviousControl.Name
Err.Clear
If (Not Form.NewRecord) Then
DoCmd.RunCommand acCmdDeleteRecord
End If
If (Form.NewRecord And Not Form.Dirty) Then
Beep
End If
If (Form.NewRecord And Form.Dirty) Then
DoCmd.RunCommand acCmdUndo
End If
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
cmdDelete_Click_Exit:
Exit Sub
cmdDelete_Click_Err:
MsgBox Error$
Resume cmdDelete_Click_Exit
End Sub