Forum Discussion
Willem1310
Oct 08, 2024Copper Contributor
Delete a record in a table from a report
Who can help me, I made a rapport from a table, I want to make a button in the rapport which deletes the record in the table. I did try to use a macro RecordDelete and assign it to a button, but wh...
Ken_Sheridan
Oct 09, 2024Brass Contributor
It can be done in a report opened in Report View. Add a button to the report's Detail section, with code like this in its Click event procedure:
Dim strSQL As String
strSQL = "DELETE * FROM Contacts WHERE ContactID = " & Me.ContactID
CurrentDb.Execute strSQL, dbFailOnError
Me.Requery
where ContactID is the primary key of a Contacts table to which the report is bound.
But why would you want to do this in a report rather than a form? The latter gives you much more control over the process. For examples of what can be done in a bound form take a look at DeleteDemo.zip in my public databases folder at:
https://1drv.ms/f/c/44cc60d7fea42912/EhIppP7XYMwggESpAAAAAAABaDKZCllSuweYBPJ5zKa3cg