Working With Class Modules

D

Devlin

I am working with class modules and have dedicated several to particular
tables in this DB project. I am calling some of the functions within the
class objects directly without creating a new instance of the class. I am a
beginner when it comes to working with class modules.

Here is an example. I have a class module called class_stores. In this
module I have a function: DBLookUpStoreID(sStoreName as String) as Long.

I will call on this function from forms or other modules to look up the
store ID for a particular store name (i.e. lStoreID =
class_stores.DBLookUpStoreID("Giant")).

Question: Is this acceptable, or is it necessary to create a new instance of
the class each time I want to access a function?
 
N

Naresh Nichani MVP

Hi:

In VBA you have to instantiate class when calling function in class.

If you have function and it does not "logically" belong to a class place it
a plain Module and you can call without instaniating Module.

Regards,

Naresh Nichani
Microsoft Access MVP
 

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