Formatting Controls

  • Thread starter Thread starter George B.
  • Start date Start date
G

George B.

Hi,

I have a query form (screen) with two option groups
(NameOption and TitleOption) each having 3 options (AND,
OR, and NOT). When a user selects and option, I have
verbose coding to change the fore and back colors to 255
and 1677215, respecitively. On the form I want to have a
button whereby the user can clear the values in the text
boxes and reset the fore and back colors to 0 and
1677215. Ican do this by explicitly referencing each
label, but that's also verbose. How can I reference each
label in the option group controls at once to reset their
colors?

If anybody has a suggestion, I'd really appreciate it.
Looking at the VB Help and TechNet has given me pieces,
but I just can't put it all together.

Geo.
 
One method (of several) is to use the tag property of the individual controls
and set them to some common value such as "ChangeColor" and then step through
the controls collection of the form and checking the tag property for that
value. UNTESTED AIRCODE with no error handling follows.

Private Sub btnChangeColor_Click()
Dim cntlAny As Control

For Each cntlAny In Me
With cntlAny
If .Tag = "ChangeColor" Then
.BackColor = 0
.ForeColor = 1677215
End If
End With
Next cntlAny

End Sub
 
Back
Top