John Bartow
jbartow at earthlink.net
Wed Feb 19 09:19:01 CST 2003
Sorry 'bout that. Yesterday was one of those days of interruptions. I'm sure I typed that at one point but I must have deleted it while typing and talking at the same time. Thanks for the update I'll give it a try. JB "I don't even try chewing gum - I walk too much" > -----Original Message----- > From: accessd-admin at databaseadvisors.com > [mailto:accessd-admin at databaseadvisors.com] > Sent: Wednesday, February 19, 2003 7:52 AM > To: accessd at databaseadvisors.com > Subject: RE: [AccessD] need ideas > > >because other items on the form can cause the option group to change > values. > > Lol. Giving us the complete situation would help. > > You can call the click sub in the class instance for the appropriate group > to cause it to run the code for that group that toggles the label back > color. > > ldclsYesNoGrp2.mfra_Click > > Or, simply add a method to the class where you set the value of the group > and call the click event. In the class (at the bottom) add: > > '.Comments : > '.Parameters: > '.Sets : > '.Returns : > '.Created by: John W. Colby > '.Created : 2/19/2003 8:41:45 AM > Function SetGrpVal(lngVal As Long) > On Error GoTo Err_SetGrpVal > mfra.Value = lngVal > mfra_Click > Exit_SetGrpVal: > Exit Function > Err_SetGrpVal: > Select Case Err > Case 0 '.insert Errors you wish to ignore here > Resume Next > Case Else '.All other errors will trap > Beep > MsgBox Err.Description, , "Error in Function > dclsYesNoGrp.SetGrpVal" > Resume Exit_SetGrpVal > End Select > Resume 0 '.FOR TROUBLESHOOTING > End Function > > Then, to demo the usage, in the form (in my demo database) in the OnOpen > event add: > > ldclsYesNoGrp2.SetGrpVal 2 > > Notice that now as the form opens, the initialization is done, then one of > the groups is told to set it's value to 2. Since the class knows how to > do this and toggle the back colors as well - problem solved. > > Use ldclsYesNoGrpX.SetGrpVal Y wherever you need to set the group via > code - where X = the group class instance, and Y = the value to set it to. > > BTW, in case anyone is wondering, the overhead for classes is pretty > minimal. My classes have a LOT more stuff that they do to set up and tear > down. Yet the incremental memory use for my classes averages about 450 > bytes / class instance. In addition, on the machine I was testing with at > that time (most likely my old dual PII 233), the speed cost was ~.5ms / > class instance loaded. I was testing with a form that was loading 100 > class instances. The time to load the classes was ~50 ms. > > The thing to understand about classes is that as the first class opens, > all of it's code loads into memory. Each additional instance of the class > only uses memory for it's class global variables (in the header). Thus it > isn't like you are having to load the entire thing again and again. > > John W. Colby > Colby Consulting > www.ColbyConsulting.com > > -----Original Message----- > From: accessd-admin at databaseadvisors.com > [mailto:accessd-admin at databaseadvisors.com] > Sent: Tuesday, February 18, 2003 11:14 PM > To: accessd at databaseadvisors.com > Subject: RE: [AccessD] need ideas > > John & Lambert, > > I think I'm starting to understand using classes. Although in this case I > may still have to use a sub because other items on the form can cause the > option group to change values. I've tried AfterUpdate and that doesn't > cause a color change when the option group is changed via code and the > OnChange event is not available for the option group. > > Thanks a bunch for your help! > JB > > > ---------------------------------------------------- > Is email taking over your day? Manage your time with eMailBoss. > Try it free! http://www.eMailBoss.com -------------- next part -------------- A non-text attachment was scrubbed... Name: winmail.dat Type: application/ms-tnef Size: 3572 bytes Desc: not available URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030219/87160761/attachment-0002.bin>