PC Review


Reply
Thread Tools Rate Thread

Accessing Objects in another database

 
 
=?Utf-8?B?ZGJhcmFzY2g=?=
Guest
Posts: n/a
 
      8th Mar 2005
I have created objects in class modules in my access project. In another
database I want to create the object so I can use its properties. I made
sure the database has a reference to the project. i can search the object
browser and see the methods and objects. But when i try to create the object
I get a 429 error Activex can not create object . My class instancing is
PublicNotCreateable, could that be the problem. Any reason why I am getting
this error?
 
Reply With Quote
 
 
 
 
Sandra Daigle
Guest
Posts: n/a
 
      9th Mar 2005
You are on the right track - the Instancing property of the class should be
PublicNotCreatable. However there is still a problem in that in VBA classes
are not externally creatable. There are two ways around this - the first way
is to edit the attributes of the class. To do this you have to Export the
class, use a text editor to change the attributes then import the modified
class module. VBA will respect the modified attributes - it just won't let
you modify them directly. Further details on this technique can be found at:

http://www.mvps.org/access/modules/mdl0034.htm

The other method which I use is to create a helper function which also goes
into the code library. This is simply a public function which returns a new
instance of the class. So if my class is clsDog, I'll have a standard module
named basDog. In basDog I'll have

Public Function NewDog() as clsDog
set NewDog= new clsDog
End Function

One nice thing about this method is that you can add parameters to the
helper function to initialize any required properties of the class. For
example:

Public Function NewDog(intColor as integer) as clsDog
dim curDog as clsDog
set curDog= new clsDog
curDog.Color=intcolor
set NewDog=curDog
set curDog=nothing
End Function

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


dbarasch wrote:
> I have created objects in class modules in my access project. In
> another database I want to create the object so I can use its
> properties. I made sure the database has a reference to the project.
> i can search the object browser and see the methods and objects. But
> when i try to create the object I get a 429 error Activex can not
> create object . My class instancing is PublicNotCreateable, could
> that be the problem. Any reason why I am getting this error?



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
database window objects descriptions - accessing to print out Matilda Microsoft Access 2 30th Jun 2008 02:57 AM
Re: Accessing Database Objects in Access VB Code Van T. Dinh Microsoft Access 3 11th Dec 2006 12:53 PM
Accessing OLE objects =?Utf-8?B?TWFydGluIFdoaXRlc2lkZQ==?= Microsoft Access VBA Modules 2 25th Jan 2006 11:41 AM
accessing NET(C#) objects from VB6 =?Utf-8?B?QWxleCBLLg==?= Microsoft C# .NET 0 17th Sep 2004 06:57 PM
Accessing OLE objects Debbie Microsoft Access VBA Modules 0 9th Oct 2003 04:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:04 PM.