All things being equal, it would seem that
writing functions that can be used by many
different forms would be not only more elegant
but also more efficient. Is that right?
I determine where to place a function or sub based on the places from which
it may be used. If it is a common function/sub shared between particular
event procedures and is only useful in a single form, I put it in the form's
module. If it is something that might be called from multiple places, then
I'll put it in a standard module (particularly if it can be combined with
other more-general-use subs/functions and I might want to copy that module,
in toto, into another database or more).
I don't think it would be particularly "elegant" nor "efficient" to put
something that is useful only in a single form in a standard module.
Is there any loss/gain in processing efficiency
if a form is accessing an application-wide
function vs one that belongs to the form
exclusively?
Not so you'd ever notice watching the monitor. Generally, to determine if
one piece of code is more efficient than another, you have to execute it
many times (e.g., in a loop). If that is the only way you can determine,
then it seems obvious to me that it matters not a bit whether you use it, or
a slightly-less-efficient approach in the case (as most code is) where it
will be executed once or a few times.
It's not like "optimizing the inner loop of a sort algorithm" used to be,
back in the olden days of computing, on abominably slow mainframe hardware.
That could be worth some effort, and, believe me, plenty of effort was
expended on the problem. But, I don't know anybody who writes
general-purpose sort programs in Access' VBA.
Larry Linson
Microsoft Access MVP