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

own classes in library db

15 views
Skip to first unread message

Werner Seybold

unread,
Jun 20, 1999, 3:00:00 AM6/20/99
to
Hi!

I declared two own classes in an MDB-file I use as a module library.
Within this file both classes can be properly instantiated and the
rusulting object work flawlessly. The problem is - both classes are NOT
knowm to any object-MDB that links to the library. All subs and
functions from other modules of the library can be accessed, only the
names of both classes are unknown to the object db.

What am I doing wrong?

Werner Seybold

Dev Ashish

unread,
Jun 21, 1999, 3:00:00 AM6/21/99
to
HI Werner,

Nothing that you're doing wrong. It's just not supported, directly.

< http://home.att.net/~dashish/modules/mdl0034.htm >

-- Dev

Werner Seybold <W.Se...@t-online.de> wrote in message
news:376CD52D...@t-online.de...
: Hi!

Terry Kreft

unread,
Jun 21, 1999, 3:00:00 AM6/21/99
to
You're not doing anything wrong, this is by design.

Ther are two ways around this.

A) The "Proper" way
Create a function in a standard module in your Library database which
returns an instance of your class.

e.g. Class4 has the following method

Function Hello()
MsgBox "Hello from class4"
End Function

In the library database create a function such as
Function NewClass4() As Class4
Dim cClass4 As New Class4
Set NewClass4 = cClass4
End Function

In the client database you could then use code like this
Dim loObj As Object
Set loObj = Testletts.NewClass4
Call loObj.hello


B) The "Hack" (also known as "do this at your own peril")
1. Select the class in the database window (This example uses a class
called Class1)
2. Select the File/Save As... menu item
3. Choose the "To an external database" option on the Save As ... dialog
4. Choose Text Files as the "Save as type" in the Save Module dialog
5. Click Export
6. Rename the Class module in the database window (add_bak to the name)
7. Open the text file you've just saved and at the top of the file
you'll find the following lines
Attribute VB_Name = "Class1"
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

8. Change the line
Attribute VB_Exposed = False
to
Attribute VB_Exposed = True
9. Create a new class in the library database with the same name as the
old class
10. In design view for the new class choose the Insert/File... menu item
11. Find and select the file you've just edited

You now have an externally creatable class module.

Lyle Fairfield

unread,
Jun 22, 1999, 3:00:00 AM6/22/99
to
Hi Terry

Do you know of any reports of problems with this? Seems to work great and I
am using it more and more.

--
Lyle

Terry Kreft <terry...@mps.co.uk> wrote in message
news:7kni32$bqt$1...@gate.mps.co.uk...


> B) The "Hack" (also known as "do this at your own peril")

Terry Kreft

unread,
Jun 22, 1999, 3:00:00 AM6/22/99
to
Hi Lyle,
No I don't but, as you know, MichKa made a comment about this (i.e. it's
unsupported and do it at your own risk, etc.) the last time I posted it, and
not being one to tempt fate, I thought I'd include the caveat this time
around.


Lyle Fairfield <lyle...@cgocable.net> wrote in message
news:7koafp$fet$1...@usenet48.supernews.com...

Steve Arbaugh

unread,
Jun 24, 1999, 3:00:00 AM6/24/99
to
The only issue we'd found with this is that you can't do it in A2000 (at
least directly.) The workaround is to export the db from A2000 to an A97
db, run the same rube, and then reconvert.... Otherwise we've seen no
trouble with this method, but it IS unsupported. Using a function call to
create the object from the library, although not as elegant (and it doesn't
support early binding) works just fine too.

--
Steve Arbaugh
ATTAC Consulting Group
http://ourworld.compuserve.com/homepages/attac-cg

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

news:7ktb52$1ir$1...@gate.mps.co.uk...

Michael (michka) Kaplan

unread,
Jun 24, 1999, 3:00:00 AM6/24/99
to
Huh? I have seen many people do this in Access 2000. Directly through the
extensibility model, in fact.

The caution still stands. Be careful....

--
MichKa

-------------------------------------
random junk of dubious value is at:
http://www.trigeminal.com

Steve Arbaugh <75323...@nspm.compuserve.com> wrote in message
news:7ku2l7$gng$1...@nntp3.atl.mindspring.net...

0 new messages