John Bartow
jbartow at earthlink.net
Wed Feb 19 12:12:00 CST 2003
John,
Thanks for the info. I will be back at this in a couple of hours and would
appreciate a copy of your new demo.
JB
> -----Original Message-----
> From: accessd-admin at databaseadvisors.com
> [mailto:accessd-admin at databaseadvisors.com]
> Sent: Wednesday, February 19, 2003 11:08 AM
> To: accessd at databaseadvisors.com
> Subject: RE: [AccessD] need ideas
>
> John,
>
> I forgot to mention that you will also need to add a collection in the
> form where you will store the pointer to the classes so that they don't
> immediately unload again. Using the method I showed previously, you had a
> physical variable dimensioned for each class. Now you want to automate
> the thing so that as many classes load as are needed. This works but the
> pointer to the class has to be stored somewhere. That somewhere would be
> the collection. You also need to build a function specifically for
> instantiating the class. The new form code would look like:
>
>
> 'dim a collection to hold the class pointers
> Private colClsPtrs As Collection
>
> 'set constants to the colors
> Const clngGreen = 65280
> Const clngRed = 255
> '
> 'This function instantiates one instance of the class and stores it into
> the
> 'collection, with the key being the frame name
> '
> Function InstantiateClass(fra As Access.OptionGroup, _
> OptYes As OptionButton, _
> OptNo As OptionButton, _
> lngColorYes As Long, _
> lngColorNo As Long)
> Dim ldclsYesNoGrp As dclsYesNoGrp
>
> 'instantiate the class instance
> Set ldclsYesNoGrp = New dclsYesNoGrp
>
> 'Initialize the instance with the data passed in
> ldclsYesNoGrp.Init fra, OptYes, OptNo, lngColorYes, lngColorNo
>
> 'Add this instance to the collection
> colClsPtrs.Add ldclsYesNoGrp, fra.Name
> End Function
>
> Private Sub Form_Open(Cancel As Integer)
>
> Set colClsPtrs = New Collection
>
> 'Initialize the class variables, passing in a pointer to the frame,
> 'the check boxes, and the color constants
> InstantiateClass Frame0, Option3, Option5, clngGreen, clngRed
> InstantiateClass Frame7, Option9, Option11, clngGreen, clngRed
>
> 'the old way of referencing the class instance for a group
> 'ldclsYesNoGrp2.SetGrpVal 2
>
> 'The new way of referencing the class instance for a group
> colClsPtrs("Frame7").SetGrpVal 2
> End Sub
>
> I have modified my demo to add another form that adds the classes into a
> collection and it is available to anyone who wants it.
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>
> -----Original Message-----
> From: accessd-admin at databaseadvisors.com
> [mailto:accessd-admin at databaseadvisors.com]
> Sent: Wednesday, February 19, 2003 10:16 AM
> To: accessd at databaseadvisors.com
> Subject: RE: [AccessD] need ideas
>
> John,
> Is it acceptable to reference the collection of the OptionGroup which was
> passed by ref to the class?
>
> I was thinking that if it was then I could traverse the collection to find
> the OptionButton which has the same value as the OptionGroup and the based
> on the value color the label.
>
> My goal being that I could traverse the Form's control collection on the
> OnOpen event and instantiate all of the OptionGroups in one statement
> rather than having to organically know and type in the names of all the
> frames and option buttons.
>
> 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: 3196 bytes
Desc: not available
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030219/42f035f3/attachment-0002.bin>