VBA Code Written Once For All My Forms

  • Thread starter Thread starter VWP1
  • Start date Start date
V

VWP1

I have a couple procedures that I use for dozens of forms in teh same
database. The code for this prodecure is identical. It's not in every form,
but many. Can I reference such a procedure from any form I want, but write
the procedure once?
 
I have a couple procedures that I use for dozens of forms in teh same
database. The code for this prodecure is identical. It's not in every form,
but many. Can I reference such a procedure from any form I want, but write
the procedure once?

The usual way is to place the procedure in a module, then call if from
any of the forms.

Public Sub MyProcedureName()
' Do Something here
End Sub

Then call it from a form:
MyProcedureName

Make sure the name of the module is not the same as the name of the
Sub Procedure
 
Back
Top