PC Review


Reply
Thread Tools Rate Thread

Still getting error 2501 on DeleteRecord

 
 
=?Utf-8?B?QmFieSBGYWNlIExlZQ==?=
Guest
Posts: n/a
 
      19th Mar 2006
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


 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      20th Mar 2006
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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmFieSBGYWNlIExlZQ==?=
Guest
Posts: n/a
 
      23rd Mar 2006
Just wanted to reply to say thanks to Allen for his response but I've found
out (at last) what the problem was - having also experienced peculiar
'errors' within Trevor Best's domain aggregate functions (tLookup etc...) :

Within the Visual Basic window, click on Tools/Options and then the General
tab and under Error Trapping, set the option to 'Break on Unhandled Errors'.
This is the default setting but somehow (and I haven't a clue how!) it had
been set to 'Break on all errors'.

Anyway, thought this might help some other poor soul scratching around for a
similar solution.

Regards,

Lee

"Allen Browne" wrote:

> 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DeleteRecord =?Utf-8?B?Z2xuYm56?= Microsoft Access Form Coding 1 14th Oct 2006 01:51 PM
The Command or Action 'DeleteRecord' isn't available now EE Microsoft Access Forms 0 8th Aug 2004 01:03 AM
DeleteRecord error on an open form Ben Microsoft Access Forms 3 10th Jul 2003 07:43 PM
DeleteRecord error on an open form Ben Microsoft Access 2 10th Jul 2003 07:43 PM
DeleteRecord error on an open form Ben Microsoft Access Form Coding 2 10th Jul 2003 07:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:11 PM.