Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2005

Tip: Looking for answers? Try searching our database.

Reference Class Module in Other Database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Can - 09 Dec 2005 20:19 GMT
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
Pat Hartman(MVP) - 09 Dec 2005 21:35 GMT
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 am trying to references a class module in another database
>
[quoted text clipped - 21 lines]
>
> Can
RoyVidar - 11 Dec 2005 17:10 GMT
Pat Hartman(MVP) wrote in message
<O69KshQ$FHA.3804@TK2MSFTNGP14.phx.gbl> :
> I think that class modules are only available when the object to which they
> belong is open.
[quoted text clipped - 25 lines]
>>
>> Can

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 ...

Signature

Roy-Vidar

Can - 12 Dec 2005 16:18 GMT
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

> Pat Hartman(MVP) wrote in message
> <O69KshQ$FHA.3804@TK2MSFTNGP14.phx.gbl> :
[quoted text clipped - 56 lines]
>
> Then you should be able to use it's properties and methods ...
RoyVidar - 12 Dec 2005 17:35 GMT
Can wrote in message
<ADB29FF0-2F4B-4FA0-BC6B-700BCC7E36FE@microsoft.com> :

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

> The reference worked great but I have another problem.  
>
[quoted text clipped - 76 lines]
>>
>> Then you should be able to use it's properties and methods ...

Signature

Roy-Vidar

Can - 13 Dec 2005 18:56 GMT
Worked like a charm.

> Can wrote in message
> <ADB29FF0-2F4B-4FA0-BC6B-700BCC7E36FE@microsoft.com> :
[quoted text clipped - 87 lines]
> >>
> >> Then you should be able to use it's properties and methods ...
Can - 14 Dec 2005 19:37 GMT
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

> Can wrote in message
> <ADB29FF0-2F4B-4FA0-BC6B-700BCC7E36FE@microsoft.com> :
[quoted text clipped - 87 lines]
> >>
> >> Then you should be able to use it's properties and methods ...
RoyVidar - 14 Dec 2005 20:09 GMT
Can wrote in message
<4B6FC5B2-1A37-46BB-A8AD-EED8B6B812E9@microsoft.com> :

Sorry, I don't know. Could it be something wihin the function? I mean,
would it return something if you just assigned True?

> Okay so it didn't quiet work like a charm.  I am able to set
>
[quoted text clipped - 9 lines]
> Here's the declaration of the function from the class module
> Public Function CheckConnection(ConnectionString As String) As Boolean

Signature

Roy-Vidar

Can - 19 Dec 2005 19:22 GMT
Function is fine.  I tried just assigning true and it gave me the same
error.  Any other ideas?

> Can wrote in message
> <4B6FC5B2-1A37-46BB-A8AD-EED8B6B812E9@microsoft.com> :
[quoted text clipped - 15 lines]
> > Here's the declaration of the function from the class module
> > Public Function CheckConnection(ConnectionString As String) As Boolean
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.