I
If
Good evening,
I have a form with a subform.
I want to create a button that can delete a highlighted record within the
subform.
I found the code below but it gives me the message : 'The command or action
"DeleteRecord" isn't available now."
How can I removed a recording in this way?
--------------------------------------------
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
DoCmd.SetWarnings False
If MsgBox("Confirm deletion of the record?", _
vbQuestion + vbYesNo + vbDefaultButton2, _
"Delete?") = vbYes Then
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
End If
Exit_cmdDelete_Click:
DoCmd.SetWarnings True
Exit Sub
Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click
End Sub
--------------------------------------------
I have a form with a subform.
I want to create a button that can delete a highlighted record within the
subform.
I found the code below but it gives me the message : 'The command or action
"DeleteRecord" isn't available now."
How can I removed a recording in this way?
--------------------------------------------
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
DoCmd.SetWarnings False
If MsgBox("Confirm deletion of the record?", _
vbQuestion + vbYesNo + vbDefaultButton2, _
"Delete?") = vbYes Then
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
End If
Exit_cmdDelete_Click:
DoCmd.SetWarnings True
Exit Sub
Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click
End Sub
--------------------------------------------