Wanna be my hero? Here's your chance!
I'm working on another database but to make this case simpler, I started from a scratch and created a new and really simple database. It only has one table (with 3 fields) and one form based on that table.
Then, I created a "delete" button on the form using the button wizard, for the purpose of having option to delete individual records (simple, right?). I then created 5 different records.
Now, if I use that button to delete a record, a message pops up that says "You are about to delete one record(s)! Are you sure..?" If I click YES, it deletes it like it should. If I click NO, I get an error message that says "Run-time error: 2501, The DoMenuItem action was canceled".
I looked everywhere and found a few solutions how to trap this error, but none of them worked for me.
I tried one that apparently worked for someone else, but not for me. The dreaded error message still pops up if I cancel delete.
I think that routine (for some reason) never reaches and executes the "If err" part. I simplified that part even further by replacing it with:
just to see if anything happens (the idea was to display a little "test" message box if any error occurs.) Still nothing
I don't know if this is some kind of bug in Access2000, and error 2501 just can't be handled, or I'm just missing something, but I'm slowly going crazy after spending a whole day on the stupid error message.
Thanks in advance.
I'm working on another database but to make this case simpler, I started from a scratch and created a new and really simple database. It only has one table (with 3 fields) and one form based on that table.
Then, I created a "delete" button on the form using the button wizard, for the purpose of having option to delete individual records (simple, right?). I then created 5 different records.
Now, if I use that button to delete a record, a message pops up that says "You are about to delete one record(s)! Are you sure..?" If I click YES, it deletes it like it should. If I click NO, I get an error message that says "Run-time error: 2501, The DoMenuItem action was canceled".
I looked everywhere and found a few solutions how to trap this error, but none of them worked for me.


Code:
Private Sub btnDelete_Click()
On Error GoTo Err_btnDelete_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
If Err Then
If Err.Number = 2501 Then
Err.Clear
End If
End If
Exit_btnDelete_Click:
Exit Sub
Err_btnDelete_Click:
MsgBox Err.Description
Resume Exit_btnDelete_Click
End Sub
Code:
If Err Then
MsgBox "test"
End If

I don't know if this is some kind of bug in Access2000, and error 2501 just can't be handled, or I'm just missing something, but I'm slowly going crazy after spending a whole day on the stupid error message.
Thanks in advance.