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
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!
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.
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")
Lyle Fairfield <lyle...@cgocable.net> wrote in message
news:7koafp$fet$1...@usenet48.supernews.com...
--
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...
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...