Add custom button to form or detail view

Add custom button to form or detail view

Is there a way to add a custom button to either the form or the detail view from a report? I have a function I'd like to execute when the button is clicked that needs the record ID of the item being viewed. I'm not asking about adding a button to each row of the report. I've figured out how to do that, but it isn't ideal because I need to allow the users to view and update the items on a subform before they perform the action.

Something like this:



or this: