Answer for Appache

W

Wayne-I-M

Here is the answer
(to "change the colour of a Label in response to an action")

Place these codes on your form (open it in design view and right click the
CheckBox – not the lable)

I have assumed that your labels are called [LableA1] and [LableA2] so you
will need to change these on your code. Also change the colours to whatever
you want.

Place this on the AfterUpdate

Private Sub MycheckboxName_AfterUpdate()
On Error GoTo MycheckboxName_AfterUpdate_Err

If Me.MycheckboxName = 1 = True Then
Me.LabelA1.BackColor = vbYellow
Me.LabelA1.ForeColor = vbRed
Me.LableA1.FontBold = True
Else
Me.LabelA1.BackColor = vbBlack
Me.LabelA1.ForeColor = vbGreen
Me.LableA1.FontBold = False
End If

If Me.MycheckboxName = 1 = True Then
Me.LabelA2.BackColor = vbYellow
Me.LabelA2.ForeColor = vbRed
Me.LableA2.FontBold = True
Else
Me.LabelA2.BackColor = vbBlack
Me.LabelA2.ForeColor = vbGreen
Me.LableA2.FontBold = False
End If

End Sub

Place this on the OnActivate of the “form†- NOT the Label. (right click
the grey area outside the designed section of your form)

Private Sub Form_Activate()
If Me.MycheckboxName = 1 = True Then
Me.LabelA1.BackColor = vbYellow
Me.LabelA1.ForeColor = vbRed
Me.LableA1.FontBold = True
Else
Me.LabelA1.BackColor = vbBlack
Me.LabelA1.ForeColor = vbGreen
Me.LableA1.FontBold = False
End If

If Me.MycheckboxName = 1 = True Then
Me.LabelA2.BackColor = vbYellow
Me.LabelA2.ForeColor = vbRed
Me.LableA2.FontBold = True
Else
Me.LabelA2.BackColor = vbBlack
Me.LabelA2.ForeColor = vbGreen
Me.LableA2.FontBold = False
End If

End Sub



Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top