Delete Record code not working

  • Thread starter mlkiser via AccessMonster.com
  • Start date
M

mlkiser via AccessMonster.com

I am using the following code based on several posts I have found on this
great site:

Private Sub cmdDelete_Click()
If Me.Dirty Then Me.Undo

If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If

End Sub

When I try to use this code to delete a record, I get the following error
message:

Run-time error '2046':
The command or action 'DeleteRecord' isn't avaialble now.

I tried adding Do.Cmd in front of RunCommand and that made no difference. Not
sure what I am doing wrong.
 
J

John Spencer

Actually it is

DoCmd.RunCommand acCmdDeleteRecord


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
J

John Spencer

Are deletes allowed on the form?

Try adding

Me.AllowDeletions = True
DoCmd.RunCommand acCmdDeleteRecord

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

mlkiser via AccessMonster.com said:
I tried that first. Same error message.

John said:
Actually it is

DoCmd.RunCommand acCmdDeleteRecord
I am using the following code based on several posts I have found on this
great site:
[quoted text clipped - 17 lines]
Not
sure what I am doing wrong.
 

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