You have handled error 2501 in cmdDelete_Click, so the error must be from
another event.
When the error occurs, the built-in error message has buttons for Debug and
End. Choose Debug, and you can see the event that is generating the error
(e.g. Form_BeforeDelConfirm, or Form_Current). Add the same kind of
error-handling to that event also.
This is usually only a problem with Access 2002 Service Pack 3.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Baby Face Lee" <(E-Mail Removed)> wrote in message
news:35D1FE69-48D5-4B29-9FBB-(E-Mail Removed)...
> Hi everyone
> I'm sure it's me being dim but I can't see why I'm still getting a 2501
> runtime error when the user wishes to cancel a DeleteRecord action.
>
> Here's my code on the BEFOREDELCONFIRM event of the FORM:
>
> Dim intResponse As Integer
> intResponse = MsgBox("You are about to delete a Candidate record."
> _
> & vbCrLf & "Any Components recorded for the Candidate will also be
> deleted." _
> & vbCrLf & vbCrLf & "Click on OK to proceed. This process cannot
> be
> undone." _
> & vbCrLf & vbCrLf & "Click on Cancel to exit the deletion
> process.", _
> vbExclamation + vbOKCancel + vbDefaultButton2, "WARNING!!!")
> If intResponse = vbCancel Then
> Cancel = True
> ElseIf intResponse = vbOK Then
> Response = acDataErrContinue
> End If
>
> Here's my code in the ONCLICK event of the command button CmdDelete:
> Private Sub cmdDelete_Click()
> On Error GoTo Handle_Err
>
> If Not Me.NewRecord Then
> RunCommand acCmdDeleteRecord
> End If
>
> Handle_Exit:
> Exit Sub
> Handle_Err:
> Select Case Err.Number
> Case 2501
> ' the RunCommand action was cancelled.
> Resume Handle_Exit
> Case Else
> MsgBox Err.Number & ": " & Err.Description _
> & vbCr & "Please contact Linda Lawson.", _
> "Unknown error"
> Resume Handle_Exit
> End Select
> End Sub
>
> How can I stop this error appearing?
>
> Thanks for any help you can give.
>
> Lee