Jim DeMarco
Jdemarco at hshhp.org
Fri Jun 6 10:27:46 CDT 2003
Public Not Creatable is a VB thing. I use it when I create a class that I'm going to implement via a custom collection class. I set the object class to PublicNotCreateable and the collection to PublicCreatable. This allows me to loop through a custom collection using this syntax: <snip> Dim CustomObject As cCustomObject 'can declare and return them but can't instantiate them Dim MyCustomObjectCollection As cCustomObjectCollection For each CustomObject In MyCustomObjectCollection 'do something here Next </snip> This as opposed to using a Variant to store CustomObject. This provides something similar to the strong typing you get in .NET. Jim DeMarco Director of Product Development HealthSource/Hudson Health Plan -----Original Message----- From: Bob Bedell [mailto:bobbedell15 at msn.com] Sent: Friday, June 06, 2003 11:18 AM To: accessd at databaseadvisors.com Subject: RE: [AccessD] Where does WithEvents go? >I guess that since Microsoft considers VBA developers to be children, >giving us such powers is >considered dangerous - This really is kinda' bizarre when you think about it. All Microsoft would need to do is add one more item to the Instancing Enum: 3- PublicCreatable. Then - 1 - Private: Attribute VB_Exposed = False, Attribute VB_Creatable = False 2 - PublicNotCreatable: Attribute VB_Exposed = True, Attribute VB_Creatable = False 3 - PublicCreateable: Attribute VB_Exposed = True, Attribute VB_Creatable = True What we need is 3, and that's the one setting they don't provide. I wonder what the point of 2 is anyway: why expose a class and then prevent anyone from instantiating objects from it? Go figure. Access 11? >From: "Bob Bedell" <bobbedell15 at msn.com> >Reply-To: accessd at databaseadvisors.com >To: accessd at databaseadvisors.com >Subject: RE: [AccessD] Where does WithEvents go? >Date: Fri, 06 Jun 2003 14:01:56 +0000 > >Outstanding! Phenonmenal! This is great! Think of the endless >possibilities! > >Oh, it worked... > >That's great John. clsInventory is now "creatably" exposed to my event sink >app, with custom events firing and all. Thanks for adding several >productive years to my life. > >Bob > > >>From: "John Colby" <jcolby at colbyconsulting.com> >>Reply-To: accessd at databaseadvisors.com >>To: <accessd at databaseadvisors.com> >>Subject: RE: [AccessD] Where does WithEvents go? >>Date: Fri, 6 Jun 2003 08:56:25 -0400 >> >>Bob, >> >>Classes built directly in a library database are not visible outside of >>the >>library in VBA. No Se Por Que. I guess that since Microsoft considers >>VBA >>developers to be children, giving us such powers is considered dangerous - >>kinda like playing with knives or matches I suppose. At any rate, it >>absolutely is possible to get your classes exposed such that they can be >>seen and used outside of the library. >> >>The easiest way to do this is to: >> >>1) Export the class to a text file. >>2) Open the class module with a text editor >>3) Look for two attributes at the top of the module. Change Creatable and >>Exposed to True. >>4) Save the class and close the text file. >>5) In your library, click Insert / Class module >>6) In the editor window that opens, click Insert / File. Navigate to and >>select the txt file that you saved the class in. This will cause Access >>to >>pull in the contents of whatever file you selected and insert it in your >>class. In this case it is the contents of the modified class. >>7) At the top of the class you will see something like: >> >>Option Compare Database >>Option Explicit >> >>VERSION 1.0 CLASS >>BEGIN >> MultiUse = -1 'True >>End >>Option Compare Database >>Option Explicit >> >>Select and delete everything from the first Option down through the End. >> >>8) Compile and save the class >> >>The class will now be visible from any database that references your >>library. >>John W. Colby >>www.colbyconsulting.com >> >> -----Original Message----- >> From: accessd-bounces at databaseadvisors.com >>[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Bob Bedell >> Sent: Friday, June 06, 2003 2:22 AM >> To: accessD at databaseadvisors.com >> Subject: [AccessD] Where does WithEvents go? >> >> >> I hope I can make this intelligible. Info on this issue seems a bit >>sparse. I have a custom class and a form that work fine together. The >>class >>declares a custom event using Public Event syntax in the general >>declaration >>and Raise syntax in a method. The calling class (the form) declares a >>private instance of the class using WithEvents and instantiates it. No >>problems. >> >> >> >> Now I'm trying to import the class into a library (mda.) and set a >>reference to it in the database that contains the calling form. It's my >>understanding that my calling application can't instantiate the class >>directly, and needs to use a wrapper function. So I added a standard >>module >>to the calling application that calls a function in the library database >>which returns a copy of the object. The calling database then has a >>public, >>shared copy of the object to work with. The standard module in the calling >>database is: >> >> >> >> Public g_oInventory As clsInventory >> >> >> >> Public Sub Startup() >> >> ' Get handles to shared objects >> >> Set g_objInventory = GetclsInventory >> >> >> >> DoCmd.OpenForm "frmInventory" >> >> End Sub >> >> >> >> The standard module in the library database (where the class is >>located) >>is: >> >> >> >> Public Function GetclsInventory() >> >> Dim objInventory As clsInventory >> >> Set GetclsInventory = New clsInventory >> >> End Function >> >> >> >> Here's my problem. Using the library scenario, I can't find any place >>to >>put my WithEvents statement. The old declaration (before seperating the >>class and the form) was in the forms general declaration: >> >> >> >> Private WithEvents m_objProduct As clsInventory >> >> >> >> But now (library scenario) the declaration needs to be global, needs >>to >>include WithEvents, and needs to be in a class or form module (WithEvents >>won't work in a standard module). >> >> >> >> Should I do a VB ActiveX component instead? I'm kinda' at a loss here. >>Real limited experience with classes/libraries stuff. Thanks to anyone who >>can make heads or tails of that. >> >> >> >> Bob >> >> >>_______________________________________________ >>AccessD mailing list >>AccessD at databaseadvisors.com >>http://databaseadvisors.com/mailman/listinfo/accessd >>Website: http://www.databaseadvisors.com > >_________________________________________________________________ >Add photos to your messages with MSN 8. Get 2 months FREE*. >http://join.msn.com/?page=features/featuredemail > >_______________________________________________ >AccessD mailing list >AccessD at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/accessd >Website: http://www.databaseadvisors.com _________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com *********************************************************************************** "This electronic message is intended to be for the use only of the named recipient, and may contain information from Hudson Health Plan (HHP) that is confidential or privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited. If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message. Thank You". ***********************************************************************************