S
scottyb121 via AccessMonster.com
I am trying to delete a record using a command button on the onclick event
procedure in my patient form. When I click yes on the MsgBox I get a
RunCommand action was canceled error and the record is not deleted. I have
the EXACT same code for a schedule record on a schedule form and it works
just fine. I have the allow deletions property to yes on the form so that
isn't it. I am completely stumped. Here is my code for deleting a record in
the patient form.
response = MsgBox("You are about to delete this Patient record. " & _
vbCrLf & vbCrLf & _
"Are you sure you want to do this?" & vbCrLf & vbCrLf &
_
" YES - Delete this Patient record" & vbCrLf & _
" NO - Do NOT delete this Patient record" & vbCrLf, _
vbYesNo + vbDefaultButton2 + vbQuestion, _
"Confirm Patient Record Deletion")
If response = vbYes Then
DoCmd.RunCommand acCmdSelectRecord
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
DoCmd.Close
End If
procedure in my patient form. When I click yes on the MsgBox I get a
RunCommand action was canceled error and the record is not deleted. I have
the EXACT same code for a schedule record on a schedule form and it works
just fine. I have the allow deletions property to yes on the form so that
isn't it. I am completely stumped. Here is my code for deleting a record in
the patient form.
response = MsgBox("You are about to delete this Patient record. " & _
vbCrLf & vbCrLf & _
"Are you sure you want to do this?" & vbCrLf & vbCrLf &
_
" YES - Delete this Patient record" & vbCrLf & _
" NO - Do NOT delete this Patient record" & vbCrLf, _
vbYesNo + vbDefaultButton2 + vbQuestion, _
"Confirm Patient Record Deletion")
If response = vbYes Then
DoCmd.RunCommand acCmdSelectRecord
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
DoCmd.Close
End If