global vs local procedure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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!
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top