Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call routines in class modules?

Status
Not open for further replies.

WarnerSmidt

Programmer
Apr 5, 2005
8
0
0
US
I am using Access 2000 with MDA files containing routines that are used across several frontend applications. I am also using class modules, but due to the limitations of A2K, the class modules must be located in the frontend or open/called/closed via a routine located in the MDA that contains the class module. Class modules located in MDA cannot be called directly from the frontend. Has this limitation been eliminated in Access 2003?
 
Hallo,

Routines in Class modules can only be called if you have an object of that class. If you can create an object of that class, or get some sort of pointer to an existing object of the class then you can call routines in the class, otherwise the routine technically doesn't exist.

I don't suppose that helps,

- Frink
 
Modules: Creating a reference to a Class in a Library database
Author(s)
Terry Kreft


(Special thanks to Steve Arbaugh for pointing this out online, based on the findings of Michael Kaplan originally.)

When we set a reference to library (MDA) database, normally the class modules in the MDA are not visible, while standard modules are. In order to create an instance of a Class residing in an MDA, you have to follow one of these two ways.

The easiest way is to write a function in your Library db which returns an instance of your class.

The second one is a bit more involved.

1) Select the Class module in the DB window
2) Choose the "File, Save As/Export..." menu item
3) Choose "To an External File or database" from the dialog and click OK.
(Should be the default anyway)
4) Change the Save as type to "Text Files ..." and click export
5) Locate the file you have saved and open it in a text editor
At the top of the file you will find the following line
Attribute VB_Exposed = False
Change this to
Attribute VB_Exposed = True
and save the file
6) Rename your Class module
7) Create a new empty class module with the old name
8) In design view for the new Class module -
Go to the "Insert, File..." menu item and select the amended text file.

That is it, you now have an externally creatable class.



Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top