Delete Record

  • Thread starter Scott_66701 via AccessMonster.com
  • Start date
S

Scott_66701 via AccessMonster.com

Hi, I made a button to delete the record and when i press it it says:

"The Command or Action "DeleteRecord" isn't available now."

Does anyone know why I'm not allowed to delete the record.
 
A

Allen Browne

Try an event procedure like this:

Private Sub cmdDelete_Click()
If Me.Dirty Then Me.Undo
If Not Me.NewRecord Then RunCommand acCmdDeleteRecord
End Sub

This should work if:
a) Your form is bound to a table or an updatable query, and
b) Its AllowDeletions property is Yes.
 
A

Allen Browne

Without having to turn off any warnings, you could delete from the form's
clone set:

Private Sub cmdDelete_Click()
If Me.Dirty Then Me.Undo
If Not Me.NewRecord Then
With Me.RecordsetClone
.Bookmark = Me.Bookmark
.Delete
End With
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


Scott_66701 via AccessMonster.com said:
Thanks everyone. I got it fixed. Now is there a way to make it delete
the
record without bringing up the warning window asking me to press ok to
delete.

And should the problem be related to point a) (the form isn't bound to an
updatable query), see what Allen has at
http://www.allenbrowne.com/ser-61.html
Try an event procedure like this:
[quoted text clipped - 12 lines]
Does anyone know why I'm not allowed to delete the record.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top