Sharing the same code

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

Guest

Dear friends,
I have some visual basic codes for my forms and my other forms also need to
use the same code, isn't there a way by which all the forms share the same
code.
The code is for the click event of the forms' field.
 
Hello Techman.

Techman said:
Dear friends,
I have some visual basic codes for my forms and my other forms
also need to use the same code, isn't there a way by which all
the forms share the same code.
The code is for the click event of the forms' field.

Create a new Public Sub in a standard module and paste the code here.
Replace all Me's by CondeContextObject.
Call the Sub from the event procedures in your forms.
 
Another method is to use another access database and put your code into
modules. Then add this access database as a reference in your references of
the original database. The references sets up an ability to share source
code calls and functions accross multiple databases that can be called by
different forms as well as different databases that have different forms.
Best of both worlds.

Mike (smile)
 
Whether these methods are practical, of course, is dependent on exactly what
kind of code you want to share! When speaking of sharing code between forms,
people frequently are talking about such things as moving to the
next/previous/first/last record, closing forms, etc. In a case like this,
because the shared code still has to be called from the appropriate event,
you're simply exchanging one line of code for another, which really doesn't
accomplish much!

Complex tasks that are done over and over again and whose execution requires
multiple lines of code obviously would bebefit from being in a public
function.
 

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