N
night_writer
I hve a form that has checkboxes for all 50 states. Because individual
checks are hard for the user to see, I color the label of the field
when the box is checked. When the form is open and a new a box is
checked or unchecked, I run the following code for each checkbox on
the AfterUpdate event:
Private Sub chkAK_AfterUpdate()
If Me.chkAK.Value = True Then
With Me.chkAK_Label
.BackStyle = 1
.BackColor = 16762052
End With
Else
With Me.chkAK_Label
.BackStyle = 0
.BackColor = -2147483633
End With
End If
End Sub
However, I also want to check the condition of each box and color the
label appropriately when the OnCurrent event occurs for the form
itself. Right now, I am actually doing a "call" for every individual
checkbox AfterUpdate event and it gets the job done, but seems
excessively heavy handed.
I am thinking that some kind of For / Next for each control would be
much better, but I can't figure out how to go from testing the
checkbox to identifying the label that is attached to it. Because all
of my controls are named similarly, I could actually create the label
name from the checkbox name ("chk" & right(checkbox.Name,2) &
"_Label"), but that's a string. I don't know how to translate that to
refer to the label control so I can change the formatting on the
label.
Maybe I'm trying to make this too difficult. Would appreciate any
creative solutions anyone cares to offer!
Alice
checks are hard for the user to see, I color the label of the field
when the box is checked. When the form is open and a new a box is
checked or unchecked, I run the following code for each checkbox on
the AfterUpdate event:
Private Sub chkAK_AfterUpdate()
If Me.chkAK.Value = True Then
With Me.chkAK_Label
.BackStyle = 1
.BackColor = 16762052
End With
Else
With Me.chkAK_Label
.BackStyle = 0
.BackColor = -2147483633
End With
End If
End Sub
However, I also want to check the condition of each box and color the
label appropriately when the OnCurrent event occurs for the form
itself. Right now, I am actually doing a "call" for every individual
checkbox AfterUpdate event and it gets the job done, but seems
excessively heavy handed.
I am thinking that some kind of For / Next for each control would be
much better, but I can't figure out how to go from testing the
checkbox to identifying the label that is attached to it. Because all
of my controls are named similarly, I could actually create the label
name from the checkbox name ("chk" & right(checkbox.Name,2) &
"_Label"), but that's a string. I don't know how to translate that to
refer to the label control so I can change the formatting on the
label.
Maybe I'm trying to make this too difficult. Would appreciate any
creative solutions anyone cares to offer!
Alice