Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

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.


© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer