a sub is effectively a specialised version of a function, where you are discarding the result.
you must declare a procedure as a function to call it as an event handler, or, say, as a function for a menu event handler, even if you do not return a value.
eg, I have a large close button on a lot of forms, with the click event =standardclose(). I can copy the button from form to form, as it brings its code with it.
this calls
function standardclose()
with screenactiveform
docmd.close
end with
end function
------
generally speaking, I put anything I might reuse in a module. I have also ended up weith a lot of "standard" modules that I copy from project to project, so a lot of functions actually do not get used in many projects.
I tried putting all these in libraries, but gave up, as it was proving awkward to give each user his own library (due to problems setting reference libraries as relative paths). maybe every user could have shared a standard library, but I was trying to avoid that, and give each user their own dedicated code.
I expect a lot of us even end up duplicating functions, when we can't find exactly where we put them last time!