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

John Colby jwcolby at gmail.com
Fri Jun 18 07:45:36 CDT 2021


Jim, it does still work IF and ONLY IF, the Creatable property is already
set in the class.  If I have to export the class, set it True and re-import
it, the True value changes back to False on the way back in.  IOW there is
no way (that I have found) to get it set using Access 2010.  I have an old
Framework container with my old framework, where lots of the classes are
already set True, and I can instantiate those just fine.  I simply cannot
add any new classes and get the property set True.

I will almost certainly create a VM running Windows 10 and install Office
2007 which IIRC DOES allow me to set this property True and get it imported
back in.

Just a Royal PITA which I have not implemented yet.

I actually have a very powerful server which I do not keep running all the
time but which has a Windows 10 VM already set up.  I will likely turn it
on, load the VM and go test it.

My Windows laptop which I do all my dev on only has a 256 gb SSD (mostly
full) so not enough room to really bring up a Windows VM on it.

On Thu, Jun 17, 2021 at 7:13 PM Jim Dettman via AccessD <
accessd at databaseadvisors.com> wrote:

> John,
>
> << VB_Exposed=True VB_Creatable=True>>
>
>  Did it work?
>
> Jim.
>
> -----Original Message-----
> From: AccessD On Behalf Of John Colby
> Sent: Thursday, June 17, 2021 2:15 PM
> To: Access Developers discussion and problem solving <
> accessd at databaseadvisors.com>
> Subject: Re: [AccessD] Access 2010 or later - storing and referencing code
> in libraries
>
> Read this:
>
>
> https://docs.microsoft.com/en-us/openspecs/microsoft_general_purpose_programming_languages/ms-vbal/a09fd48e-abed-4da8-8c4c-a110bf4ef6b6
>
> Hidden attributes in modules
> <
> https://docs.microsoft.com/en-us/openspecs/microsoft_general_purpose_programming_languages/ms-vbal/a09fd48e-abed-4da8-8c4c-a110bf4ef6b6
> >
>
> Notice specifically Public Creatable
> TABLE 1
>
> Instancing Mode
>
> Meaning
>
> Attribute Values
>
> Private* (default)*
>
> The class is accessible only within the enclosing project.
>
>
>
> Instances of the class can only be created by modules contained within the
> project that defines the class.
>
> VB_Exposed=False VB_Creatable=False
>
> Public Not Creatable
>
> The class is accessible within the enclosing project and within projects
> that reference the enclosing project.
>
>
>
> Instances of the class can only be created by modules within the enclosing
> project. Modules in other projects can reference the class name as a
> declared type but can’t instantiate the class using new or the CreateObject
> function.
>
> VB_Exposed=True VB_Creatable=False
>
> Public Creatable
>
> The class is accessible within the enclosing project and within projects
> that reference the enclosing project.
>
>
>
> Any module that can access the class can create instances of it.
>
> VB_Exposed=True VB_Creatable=True
>
>
>
>
>
> On Thu, Jun 17, 2021 at 12:50 PM Jim Dettman via AccessD <
> accessd at databaseadvisors.com> wrote:
>
> > John,
> >
> >  Don't know the answer to this right off, but the docs/comments I find
> all
> > say that the VB_Creatable attribute is ignored with VBA.  I know you said
> > you've done this in the past, but all these docs/comments are more recent
> > and I wonder if a change might have been made, or if something else that
> > was
> > done cut the ability to do that off.
> >
> >  But I did find this, which I think you'll find interesting and may be of
> > help:
> >
> > How to use a class (object) from outside of the VBA project in which it
> is
> > declared
> >
> >
> >
> https://docs.microsoft.com/en-us/previous-versions/office/troubleshoot/offic
> > e-developer/set-up-vb-project-using-class
> > <
> https://docs.microsoft.com/en-us/previous-versions/office/troubleshoot/office-developer/set-up-vb-project-using-class
> >
> >
> >   Using a helper function, it shows how to instantiate a class in another
> > project.
> >
> > Jim.
> >
> > -----Original Message-----
> > From: AccessD On Behalf Of John Colby
> > Sent: Thursday, June 17, 2021 12:16 PM
> > To: Access Developers discussion and problem solving
> > <accessd at databaseadvisors.com>
> > Subject: [AccessD] Access 2010 or later - storing and referencing code in
> > libraries
> >
> > 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
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>
>
> --
> John W. Colby
> Colby Consulting
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
John W. Colby
Colby Consulting


More information about the AccessD mailing list