Delete Record code not working

  • Thread starter Thread starter mlkiser via AccessMonster.com
  • Start date 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.
 
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
..
 
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.
 
Back
Top