Bob Bedell
bobbedell15 at msn.com
Fri Jun 6 08:13:31 CDT 2003
Hi Shamil, Thanks for the thought. My Instancing property is, unfortunately, already set to PublicNotCreatable. My calling database can see and call an instance of GetclsInventory fine. The wrapper function returns an object with ten fingers and toes. All properties and methods, except the custom event, work fine. Here's the wrapper again (just for the sake of pointing out one thing): Public Function GetclsInventory() Dim objInventory As clsInventory Set GetclsInventory = New clsInventory End Function It seems that in order for GetclsInventory to be able to raise a custom event, the Dim line here would have to read: Dim WithEvents objInventory As clsInventory That, I assume, is where WithEvents would need to go: with the object declaration. But I can't do that here because I have the wrapper in a standard code module, and with events can only be used in form and class modules. So my options seem to be (none of which I have been able to make work) to declare objInventory in either my calling form class somehow (can't come up with a visible global variable), or in another class module in the library or calling database, or in the clsInventory class itself. I was just hoping someone would say, "Oh sure, wrapper function, goes in class w in component x. Call it with y in component z.", or "Sorry, can't raise custom events from an Access library database.", etc. >From what little I've been able to read on the subject (I found a whole paragraph in one of Wrox's Access books), the wrapper should go in a standard module in the library database. That, however, rules out the use of custom events with WithEvents). I think the Access Developer's Handbook has a sentence or several on this too. Compiling an ActiveX dll is always another option. But I wanted to give the Access library a test drive. Thanks again for the reply. Bob >From: "Shamil Salakhetdinov" <shamil at smsconsulting.spb.ru> >Reply-To: accessd at databaseadvisors.com >To: accessd at databaseadvisors.com >Subject: Re: [AccessD] Where does WithEvents go? >Date: Fri, 6 Jun 2003 12:55:25 +0400 > >Bob, > >You can set your class module's Instancing property to >'2-PublicNotCreatable' then you can continue to use it the way you used it >without library - you will just need to get its instance by your >wrapped/helper function GetclsInventory... > >HTH, >Shamil > >----- Original Message ----- > From: Bob Bedell > To: accessD at databaseadvisors.com > Sent: Friday, June 06, 2003 10:21 AM > 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 > >_______________________________________________ >AccessD mailing list >AccessD at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/accessd >Website: http://www.databaseadvisors.com _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus