Reference Class Module in Other Database

C

Can

I am trying to references a class module in another database

Dim da As NTier_Essentials.DataAccess

Where
NTier_Essentials = Project name
DataAccess = Class Module

I get "Compile Error: User-defined type not defined"

I linked the database as a reference by using Tools -> Reference. The
database and the class modules appear the project explorer so the reference
has been made. I can't seem to get the syntax correct.

The reason why I want to do it this way is because I want several databases
to access the same generic modules. If I make one change I don't want to
have to change it in 20 different databases.

Any help is appreciated.

Thanks.

Can
 
P

Pat Hartman\(MVP\)

I think that class modules are only available when the object to which they
belong is open.

If you have code you want to share, you probably should move it to a library
database and make it an add-in.
 
R

RoyVidar

Pat Hartman(MVP) wrote in message
I think that class modules are only available when the object to which they
belong is open.

If you have code you want to share, you probably should move it to a library
database and make it an add-in.

I don't see the original question on my server, but hope this
will find it's way to their server ...

I think one should be able to do this through:

In the referenced database, set the instancing property of the
class(es) to 2-PublicNotCreateable.

Still in the referenced database, insert a standard module.

Within that standard module, you create some code instantiating
the class

Public Property Get GetMyClass() as Object
Set GetMyClass = New DataAccess
End Property

Note the declaration of the return object (object, not
classname)

Then in the database where you need this class, you should be
able to instantiate through something like this:

Dim myClassObject as DataAccess

Set myClassObject = GetMyClass

Then you should be able to use it's properties and methods ...
 
C

Can

The reference worked great but I have another problem.

Public Function GetXMLfromCommandText( _
ConnectionString As String, _
CommandText As String) As Stream

but I get the error
"user-defined type not defined"

I think it is a reference issue but I am not certain.

I have the following references (in order of priority)
- Visual Basic for Applications
- Microsoft Access 9.0 Object Library
- OLE Automation
- Microsoft ActiveX Data Objects 2.1 Library
- Microsoft ADO Ext 2.7 for DDL and Security
- Microsoft DAO 3.6 Object Library
- Microsoft XML, v5.0
 
R

RoyVidar

Can wrote in message
<[email protected]> :

This is outside my little area of expertice (should I have one;-)),
but I think you'll need a newer/higher version of ADO for this,
not that I know which, but I find it in 2.5 and higher.

I'm a bit picky about explicit declarations, too;-)

.... as adodb.stream
 
C

Can

Worked like a charm.

RoyVidar said:
Can wrote in message
<[email protected]> :

This is outside my little area of expertice (should I have one;-)),
but I think you'll need a newer/higher version of ADO for this,
not that I know which, but I find it in 2.5 and higher.

I'm a bit picky about explicit declarations, too;-)

.... as adodb.stream
 
C

Can

Okay so it didn't quiet work like a charm. I am able to set

Set da = GetDataAccess

But when I try and use a function within that class module
fOK = da.CheckConnection(mstrOLEDBConnect)

I get error 424: Object Required

What am I doing wrong?

Here's the declaration of the function from the class module
Public Function CheckConnection(ConnectionString As String) As Boolean
 
C

Can

Function is fine. I tried just assigning true and it gave me the same
error. Any other ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top