Deleting a record programmatically

  • Thread starter Thread starter John S. Ford, MD
  • Start date 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
 
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
 
Back
Top