Delete Error - TheRunCommand action was canceled

Accessator

Registered User.
Local time
Today, 19:33
Joined
Aug 22, 2007
Messages
10
I got an error message in deleting some rows in Access 2003.

I don't know why this could be happened to me ? but in some rows it works fine deleting the rows.

Here's my Delete Button code:

Code:
Private Sub btnDeleteLocation_Click()
On Error GoTo Err_btnDeleteLocation_Click
    
    If MsgBox("Are you sure you want to delete this record?", vbExclamation + vbYesNo, Me.Form.Caption) = vbYes Then
        DoCmd.SetWarnings False
        DoCmd.RunCommand acCmdSelectRecord
        DoCmd.RunCommand acCmdDeleteRecord
        DoCmd.SetWarnings True
    Else 'user clicked no
        MsgBox "Deletion was aborted.", vbInformation
    End If
            
Exit_btnDeleteLocation_Click:
    Exit Sub

Err_btnDeleteLocation_Click:
    MsgBox Err.Description
    Resume Exit_btnDeleteLocation_Click
End Sub

This is the error message:

TheRunCommand action was canceled :confused::confused::confused:
 
If you leave your Warnings ON you will see why this is happening. I suspect there is no current record to select.
 

Users who are viewing this thread

Back
Top Bottom