VBA Code Written Once For All My Forms

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?
 
F

fredg

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
 

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

Top