Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete Current Record (2000)

    I'm playing around with Access VBA which I find a little esoteric at the moment. I have placed a command button on a form without using the wizard and I wish it's click event to delete the current record.
    I have the following line of code in the on click event:

    RunCommand acCmdDeleteRecord

    On clicking the button, it begins the delete process and asks me if I wish to proceed. When clicking the "No" option, an error message appears saying that the RunCommand action has been canceled and I can choose to debug or end.

    What do I need ti include to prevent this from happening?

    TIA
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Delete Current Record (2000)

    Hi Rob,

    If you want to suppress the error that occurs if the deletion is canceled, you must create an error handler:

    Private Sub cmdSomething_Click()
    On Error GoTo ErrHandler

    RunCommand acCmdDeleteRecord
    Exit Sub

    ErrHandler:
    If Err = 2501 Then
    ' Action canceled - do nothing
    Else
    ' Other error - report to user
    MsgBox Err.Description, vbExclamation
    End If
    End Sub

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Current Record (2000)

    Hi Hans

    The impenetrable black cloud has now been replaced by a dense fog. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •