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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Record 1

Status
Not open for further replies.

ecugrad

MIS
Apr 17, 2001
191
US
Question, I want to code a delete button to delete selected records from a subform. The records reside in a table called tblResults. When I use a cmdButton I get record cannot be deleted because it contains a related record in the tblResults table. This is the table I want to delete the record from. I guess it is looking and trying to delete from my tblEmployees table, which is the one to my one to many relationship. The record deletes fine if I highlight it and push delete on the keyboard.

Hoe do I mimic the code Access uses when the delete is used from a keyboard.

Thanks in advance..
 
You should be able to use a DoCmd.RunSQL combined with a DELETE FROM SQL statement

e.g.

DoCmd.RunSQL "DELETE FROM tblResults WHERE PrimKey = " & [ReferencePrimKey] James Goodman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top