global vs local procedure

J

John B. Smotherman

I have a distributed app with quite a bit of VBA for the different forms and
reports, as well as some global code in modules. My question is actually in
two-parts:

first, if I have two fields I want to perform some data verification on in
the OnBeforeUpdate event and the resulting code is almost identical except
for field names, can I modify and put the code in one of the global modules
to eliminate the duplicate subroutine?

second, in a more general vein, what's the advantage of local routines over
global routines? is it more than just pre-defined scope?

Thanks!
 
S

SteveM

You only need the routine once in your form's module, just call it from both
events.

Whenever possible, use local routines.
It makes your app much easier to maintain since you know any changes will
only affect the current form/report. It may also provide better performance
because Access does not have to load another module.

Steve
 
Top