Toolbar or Action bar. Don’t mean to be overly nit picky but the answers are different. Andre Guiard wrote a great article and app for the view that allows you to create a tool bar button them build the code to send the toolbar button out via code. As for the code, a toolbar can only run limited @Formulas, so I have used them to spawn a form in a local database that has the code I actually want it to run and this has worked quite well. Admittedly you could write a dll and extend @Formulas like the @DBLookup, so you may need to go that way.
I have used it many times and it works great! As for an Action Button, this is a bit more difficult as they are tied to the form or subform. Might be able to do it via C/C++ but I don’t know off hand.