Deleting a record programmatically

  • Thread starter John S. Ford, MD
  • Start date
J

John S. Ford, MD

What method would I use to delete the current record shown by a form? In
other words the code equivalent for going to the menu and clicking
Edit-->Delete Record. I can't seem to find it in the help files.

Thanks in advance,
John
 
J

John Nurick

Hi John,

Either use DoCmd.RunCommand acCmdDeleteRecord, or build and execute a
SQL delete statement that uses a key value picked up from the form, e.g.
(assuming there's a numeric primary key displayed in the textbox
txtKeyField):

dbengine(0)(0).Execute "DELETE FROM tblT WHERE KeyField=" _
& Me.txtKeyField.Value & ";", dbFailOnError
 

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