[AccessD] need ideas

John W. Colby jcolby at colbyconsulting.com
Tue Feb 18 16:23:01 CST 2003


John,

Not exactly.  You dim an instance of the class in each form with this kind
of Group.  If the number of groups varies from form to form then it would be
best to build a class that handles only one group.  Then you would
instantiate the class one time for each group.

However... while writing a demo for you and the group (this Withevents stuff
REALLY is easy) I discovered some interesting behavior on the part of the
option button.  When implemented as part of an option group, it cannot be
used individually as an option button. for example:

Public Sub Init(ByRef loptYes As Access.OptionButton, ByRef loptNo As
Access.OptionButton)

    'Store a pointer to the two opt button controls
    Set moptYes = loptYes
    Set moptNo = loptNo

FAILS if the two option buttons passed in are part of a group, but WORKS if
the option buttons are free standing.  The lines that SET mopt = lopt gives
a run time error saying that the controls don't support that property.

I remember running accross this before.

What that means is that if you want to do this as a group, you will have to
pass in the group as well as the radio buttons, then sink the group Click
Event.

I have developed a demo that does what you desire and will send it in
another message.

John W. Colby
Colby Consulting
www.ColbyConsulting.com

-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com]On Behalf Of John Bartow
Sent: Tuesday, February 18, 2003 12:55 PM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] need ideas


OK in both cases I need to:

find the result based on the frame's value
find the name of the radio button contained in the frame with that value
find the name of the associated label contained by that radio button
change the fore color of it as desired

So the difference between the two would be:
Sub: I would have to call a sub for every control on every form and pass it
the form and control name

WithEvents Class: I would instantiate the class once when the app starts and
it would "keep tabs" on which form and control is being used so and I would
never have to include any additional code

Is this correct?

JB


-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com]On Behalf Of Heenan, Lambert
Sent: Tuesday, February 18, 2003 11:23 AM
To: 'accessd at databaseadvisors.com'
Subject: RE: [AccessD] need ideas


Whether you use a class with WithEvents, or just a simple Sub that you call
in the option group's On_Click event, here's an example of the basic logic
that you could use to do the color changing...

Sub formatOpGroup(opGrp As OptionGroup, sCaption As String)
Dim c As Control

    For Each c In opGrp.Controls
        If TypeOf c Is Label Then
            If c.Caption = sCaption Then
                c.ForeColor = IIf(sCaption = "Yes", RGB(0, 255, 0), RGB(255,
0, 0))
            Else
                c.ForeColor = RGB(0, 0, 0)
            End If
        End If
    Next c
End Sub

Lambert

> -----Original Message-----
> From:	John Bartow [SMTP:jbartow at earthlink.net]
> Sent:	Tuesday, February 18, 2003 11:40 AM
> To:	AccessD
> Subject:	[AccessD] need ideas
>
> I'm involved in an app where the color of the associated label for radio
> buttons in a frame should change once its selected.
>
> The frames are all the same and have radio buttons with "Yes" and "No" as
> labels. They would like the NO to be red when selected and YES to be green
> when selected.
>
> I was thinking of trying a class but this seems like it would be a bit
> more
> complicated than the text box background color changing class that we've
> discussed before.
>
> Any ideas or suggestions?
>
> JB
>
>
> _______________________________________________
> 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


_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



----------------------------------------------------
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: 3680 bytes
Desc: not available
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030218/06c21453/attachment-0002.bin>


More information about the AccessD mailing list