[AccessD] Access 2010 or later - storing and referencing code in libraries

John Colby jwcolby at gmail.com
Thu Jun 17 11:15:54 CDT 2021


I need assistance creating a library file, using Access 2010, which
contains CREATABLE classes.

If you export a class made in Access 2010 using the 2007 file format, in
the header it will have a set of properties looking like this:

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "dclsFrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Compare Database
Option Explicit

Back in the day, I would change vb_Creatable as follows:

  Attribute VB_Creatable = True

What this does is allows the class to be stored in an MDS file, then
reference the MDA and use the class from there.  The vb_Creatable
propert specifically allows the class to be instantiated using "Dim MyCls
as new clsXYZ"

Without the file having the VB_Creatable = true, the class can be seen
but cannot be instantiated.

So... I export the class, I edit the file in a text editor setting
vb_Creatable = true, I reimport it back into the file.  If I export it back
out, the property has been changed back to VB_Creatable=False.

And of course, if I reference the library, and try to instantiate the class
it fails to compile.

Understand that I have the exact same code in an old MDA file.  If I open
that mda file WITH Access 2010 and export the class to a text file the
vb_Creatable is in fact True.

I am utterly failing to create an MDA file in 2007 file format which allows
me to do this thing.  I am unable to even truly create an MDA file.  I can
call it .MDA but the lock file will be .Accdb.

I can create an Accda file but it too fails to retain the vb_Creatable =
true, and any file stored in said file will not instantiate.

This is really basic stuff.  I used it for a decade to store my framework
and dozens of classes in C2DbFramework, reference the mda file and used "as
new" syntax.  I no longer can do this.I can't find any reference out on
google to doing this.  Lots of stuff about these hidden properties of
classes, most of it wrong, none of it discussing using classes from a
library file.

Help me Obi Wan...  Is there an Obi Wan left amongst us?

--
John W. Colby
Colby Consulting


More information about the AccessD mailing list