"Include" Or "Import" VBA modules

swisstoni

Registered User.
Local time
, 17:17
Joined
May 8, 2008
Messages
61
Hey guys,

Either I'm missing something really basic or it doesn't exist...

In Java for example, I could call import *** package name ***

I've written a VBA module with some standard library functions I'll want to use, how can I import that into the VBA code for a form?

Google is proving fruitless, partly because I'm not sure what to search for!

Thanks.
 
in the VBA editor, go to Tools>References, then browse...change the file filter to .mdb and select the db containing the module. It is for this reason that it is always good to change the VBA project name to something meaningful. Obviously the module has to be in database.

HTH,
Chris
 
The module I want is inside the database I'm using...

I did the above and I got:

"Name conflicts with existing module, project or object library"

Is that method meant for referencing modules from other databases?
 
You can't have two modules with same names- you will have to look for where there are same names and change one of them.

This is also true if you have a module and a function or sub with same name.
 
The module already shows up within my project... as per this screenshot:

http://img516.imageshack.us/img516/1913/shotpq5.jpg

I just right clicked my database and went to "insert module" - that's what Functions is in the screen shot.

But how can I use the functions within that module in, for example, the "Form_frmCats" code?
 
The module already shows up within my project... as per this screenshot:

http://img516.imageshack.us/img516/1913/shotpq5.jpg

I just right clicked my database and went to "insert module" - that's what Functions is in the screen shot.

But how can I use the functions within that module in, for example, the "Form_frmCats" code?

If you declare the functions you create in the Module "Functions" as Public, they can be called from anywhere in the database. VBA is not like Java, in Java everything you create is a class and must be imported or implemented in order to be used. In VBA Modules are really just containers of functions (methods). You can create Class Modules in VBA, but they are not exactly the same as Classes in Java.
 
Ahhh all I was missing was the public keyword!

Many thanks.
 

Users who are viewing this thread

Back
Top Bottom