Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

acCmdDeleteRecord NOT WORKING!! 1

Status
Not open for further replies.

Jen123

Technical User
Mar 9, 2001
64
GB
I've done search for this and nothing really similar to what is happening for me... Typical!

I need to delete the current record and therefore have been merrily using DoCmd.RunCommand acCmdDeleteRecord. I'm using a different machine and it has stopped working. Getting the errow message "Run time error 2046, the command or action 'Delete Record' isn't available"???? I'm using Access 97 (unfortunately) and was previously, so have no idea why stopped working.

Any ideas?
 
The odd thing is........ if I put the line above where I open a recordset it works, but I need to open the recordset before I delete a record.
 
Whoa. acCmdDeleteRecord works on the currently 'in-focus' bound form. So there are many ways this operation can go wrong.

If you want a sure-fire way to delete the record, run a DELETE via SQL:
Code:
strSQL = "DELETE * FROM tblETC WHERE ID = " & txtID.Value

CurrentDB.Execute strSQL, dbFailOnError
Me.Requery
 
I did originally want to go down this route, but whatever error trapping I use, I can't requery the form so that the record disappears without errors. The form is a subform in datasheet view, if that make a difference?
 
Not really. If you're getting errors, make sure that if you want a "delete button" you undo any changes that make it a 'dirty' record. If it's a newrecord, you then no longer have to delete it. But if they were editing an existing record, you use Me.Undo, where "Me." is the subform, and then delete the record.

But I'm just venturing a guess.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top