Deleting a record

tebule

Registered User.
Local time
Today, 04:27
Joined
Oct 8, 2008
Messages
38
I have a pop-up that is linked to a table. I have a button on the form to find a record, then I have a button to delete the record. the find works perfectly. The delete button is where I am having problems. The code is:

Code:
Private Sub cmdDeleteTicker_Click()
On Error GoTo Err_cmdDeleteTicker_Click

If MsgBox("Are you sure you want to delete this record?", vbYesNo, "Confirm Delete") = vbYes Then
    DoCmd.SetWarnings False
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdDeleteRecord
    DoCmd.SetWarnings True
End If
Exit_cmdDeleteTicker_Click:
    Exit Sub
Err_cmdDeleteTicker_Click:
    MsgBox Err.Description
    Resume Exit_cmdDeleteTicker_Click
    
End Sub



The error is "The command or action 'DeleteRecord' isn't available now. Any thoughts are to why this is happening?
 
Sorry never mind..... I had accidentally set the allow deletions on the form to no.
 
not sure what accmdselectrecord does

do you have a recordid, or something that can idenitfy the row

do this
If MsgBox("Are you sure you want to delete record " & the_identifier, vbYesNo, "Confirm Delete") = vbYes Then etc

which will prove you are deleting the correct record


------
now its either
docmd.deleterecord (if there is such a command)
application.runcommand accmddelete record (if there is one)

i thnk you are mixing the two syntaxes

[looks like i was mistaken in the above, as you have it sorted!]
 
Last edited:
Just FYI: DoCmd.RunCommand acCmdSelectRecord tells the app which record to delete, otherwise you are correct and I would need some sort of ID.
 

Users who are viewing this thread

Back
Top Bottom