china99boy
Registered User.
- Local time
- Yesterday, 19:57
- Joined
- Apr 27, 2006
- Messages
- 161
Ok, I have a delete query that I use to delete records form a table. I have created a form that I run that query from. It has Delete button that runs the query. After I get the message that says "You are about to delete 56 records" and I click No, I get a "run-time error '3059'. Operation Cancel by user"
I did some searching on the forum and thought I could trap this error. But I still continue to get the error at
"DoCmd.OpenQuery stDocName, acNormal, acEdit"
What am I doing wrong and how can I prevent this error from appearing when I click NO or cancel the operation.
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
Dim stDocName As String
stDocName = "qryDeleteRecords"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmdDelete_Click:
Exit Sub
cmdDelete_Error:
Select Case Err.Number
Case 3059
MsgBox "You have canceled the delete operation.", vbOKOnly, "Delete Canceled"
Exit Sub
Case Else
MsgBox "Error number: " & Err.Number & " has occurred. " & Err.Description, vbOKOnly, "Error"
End Select
Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click
End Sub
I did some searching on the forum and thought I could trap this error. But I still continue to get the error at
"DoCmd.OpenQuery stDocName, acNormal, acEdit"
What am I doing wrong and how can I prevent this error from appearing when I click NO or cancel the operation.
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
Dim stDocName As String
stDocName = "qryDeleteRecords"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_cmdDelete_Click:
Exit Sub
cmdDelete_Error:
Select Case Err.Number
Case 3059
MsgBox "You have canceled the delete operation.", vbOKOnly, "Delete Canceled"
Exit Sub
Case Else
MsgBox "Error number: " & Err.Number & " has occurred. " & Err.Description, vbOKOnly, "Error"
End Select
Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click
End Sub