Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Code DataBases and Class Modules

71 views
Skip to first unread message

Lyle Fairfield

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
Until now I have been using a DLL created in VB for common reused code, all
of it in class modules, of course. Now I want to emulate that with a code
database, and for the most part can just copy and paste the code. Great so
far.
But, the database with the reference to the code database can't see the
class modules, just the regular modules.
What am I doing wrong?

--
Lyle

Terry Kreft

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
Hi Lyle,
You're not doing anything wrong, Access class modules are not Public
createable.

There are two ways around this.

One is to create a function in your Library database which returns an
instance of your class object, the other is to export the class module to a
file, edit the file and change the
Attribute VB_Exposed = False

line to
Attribute VB_Exposed = True

and then insert the file into a new class module.


Lyle Fairfield <lyle...@cgocable.net> wrote in message
news:74gi2a$ov$1...@usenet40.supernews.com...

Lyle Fairfield

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
Thanks Terry.
I have this working now and thought that I had followed you instructions,
but in writing this I see that I did not.
I used the Application.SaveAsText to make a text copy of the class module.
At the top of the text file I found:
Attribute VB_Creatable = True
Thinking that was the attribute you named I changed it to:
Attribute VB_Creatable = False
Then I used Application.LoadFromText to recreate the class module.
And now the object browser shows the class.
So ...
I wonder why this worked, and where I can find a description of these
attributes (probably MSDN library?) and how they work.
VB_Exposed seems more pertinent to the problem.

--
Lyle

Terry Kreft <terry...@mps.co.uk> wrote in message
news:74gmu3$6jn$1...@gate.mps.co.uk...

Michael S. Kaplan

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
Actually, these flags are stripped by Access as part of the import process,
so they won't do much good. Access 97 class modules are not public, ever. In
Access 2000 they are public non-createable, which still means the instance
must be created in the referenced db, non in the referencee.

Michael

Lyle Fairfield <lyle...@cgocable.net> wrote in message

news:74gqlf$n8n$1...@usenet43.supernews.com...

Lyle Fairfield

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
After misfollowing Terry's advice I am looking at the class module in the
object browser?
--
Lyle

Michael S. Kaplan <mic...@nospam.trigeminal.com> wrote in message
news:eYE4UTfI#GA.320@upnetnews03...

Michael S. Kaplan

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
In which database? And what happens when you try to create a new instance in
the referencer db?

Michael

Lyle Fairfield <lyle...@cgocable.net> wrote in message

news:74gvfl$e0r$1...@usenet42.supernews.com...

Lyle Fairfield

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
Michael
I'm in the main database, the front end, the database that has the reference
to the code database.
I closed that database, closed Access, cold booted ... everything is as
before.
BUT ... I cannot create a new instance of the class. I can use it however in
what I suppose is its default instance:
clsThisClass.pType = DbText
etc.
So, I suppose that one of the great strengths of Classes, multiple
instances, is taken away from me?
Maybe it's back to DLLs.

Lyle


--
Lyle
Michael S. Kaplan <mic...@nospam.trigeminal.com> wrote in message

news:uCdSiPgI#GA.79@upnetnews03...

Michael S. Kaplan

unread,
Dec 7, 1998, 3:00:00 AM12/7/98
to
Well, like I said, its not createable outside of the project it exists in..
but its easy to create a function that does this, something like

Public Function QIClass1() As Class1
Set QIClass1 = New QIClass1
End Function

in a standard module.

Michael

Lyle Fairfield <lyle...@cgocable.net> wrote in message

news:74h3l3$s18$1...@usenet43.supernews.com...

Terry Kreft

unread,
Dec 8, 1998, 3:00:00 AM12/8/98
to
Hi Michael,
I'm sorry, it is creatable outside of the project.

Hi Lyle,
You seem to have misread my post, you need to change
Attribute VB_Exposed = False

to
Attribute VB_Exposed = True

not the VB_Creatable attribute.

Michael S. Kaplan <mic...@nospam.trigeminal.com> wrote in message

news:#SuOl1kI#GA.190@upnetnews03...

Lyle Fairfield

unread,
Dec 8, 1998, 3:00:00 AM12/8/98
to
Terry

I tried "ATTRIBUTE VB_Exposed = True", although I had to enter the line
(there was no exisitng "ATTRIBUTE VB_Exposed = False" line), but I did not
find that it made the class visible in the "referencer" database. I did find
a line "ATTRIBUTE VB_Creatable = True" and when I changed it to "ATTRIBUTE
VB_Creatable = False" the class did become visible but I was still not
allowed to create multiple copies of the class. I also found that the
visibility of the Class seemed erratic; Now you see me; Now you don't!
I also tried using a function in the code DB to return an reference to the
Class. I found that if the Class was invisible then the function was
invisible.
I think I am not going to use Classes in Code DBs.
I am now deciding among:
1. rewriting the classes as ordinary modules;
2. leaving them in the referencer MDB;
3. returning to the DLL idea.

Thanks for your help.

Lyle

--
Lyle
Terry Kreft <terry...@mps.co.uk> wrote in message

news:74jeqb$86f$1...@gate.mps.co.uk...

Dev Ashish

unread,
Dec 8, 1998, 3:00:00 AM12/8/98
to
Hi Lyle,

FWIW, SaveAsText or File/Save As Text do not put that line in the exported
file. Try closing the module and doing a File/SaveAs/Export to a text file.
This created the following header for me.

Attribute VB_Name = "cDirty"
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Similarly, you have to import the file I believe for things to work
properly.

-- Dev


Lyle Fairfield wrote in message <74jsku$dt2$1...@usenet41.supernews.com>...
:Terry


:
:I tried "ATTRIBUTE VB_Exposed = True", although I had to enter the line
:(there was no exisitng "ATTRIBUTE VB_Exposed = False" line), but I did not
:find that it made the class visible in the "referencer" database.

<<snip>>

Terry Kreft

unread,
Dec 10, 1998, 3:00:00 AM12/10/98
to
Hi Lyle,
The exact steps are as follows:
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.


Lyle Fairfield <lyle...@cgocable.net> wrote in message

news:74jsku$dt2$1...@usenet41.supernews.com...

Michael S. Kaplan

unread,
Dec 10, 1998, 3:00:00 AM12/10/98
to
Be really careful with this method as VBE and Access both can set it back on
you without warning (the hazards of unsupportable behavior).

Michael

Terry Kreft <terry...@mps.co.uk> wrote in message

news:74o59q$e9h$1...@gate.mps.co.uk...

Lyle Fairfield

unread,
Dec 10, 1998, 3:00:00 AM12/10/98
to
I haven't had a chance to use Terry's more precise directions yet, Michael,
and I've rewritten the Class Modules as Standard Modules, so there's no
hurry to do so; I'll have a go and that in the next week or so.
But, what do you mean by "set it back on you without warning"?
That future versions of VBA and Access may not support this?
Or
It may behave erratically, something I found (which was totally my fault as
I did not follow Terry and Dev's instructions exactly.)
While I have your attention, or anyone else's, I note MS says about DLLs:
"Components you author with Visual Basic will always support vtable
binding."

and

"In the fastest form of early binding, vtable binding, Visual Basic uses an
offset into a virtual function table, or vtable. Visual Basic use vtable
binding whenever possible."

So, I'm wondering and can't find:

What kind of binding do I get for Classes in Code dbs? ... the same, faster,
slower?

Do DLL's have any natural advantage over Code dbs other than having the
richer function set of VB available to them?

Lyle

--
Lyle
Michael S. Kaplan <mic...@nospam.trigeminal.com> wrote in message

news:ekXaIRFJ#GA.220@upnetnews03...

Michael S. Kaplan

unread,
Dec 10, 1998, 3:00:00 AM12/10/98
to
As for my comment, it is that this attribute is not one that VBA in Office
supports... ao if your app sudenly breaks, don't say I didn't warn you. I
was not making comments about future versions, I am staying rooted in the
present.

Not sure I understand the question... VB does not have a richer function set
than any Office app, its all a matter of what you reference.... and VBA
supports early binding just as VB does.

Michael

Lyle Fairfield <lyle...@cgocable.net> wrote in message

news:74ouhe$q36$1...@usenet41.supernews.com...

0 new messages