Label Formatting Question

T

TotallyConfused

The example below works. but it stays yellow for all records. I need it
only to turn yellow if checked on a specific record. How do I write this so
that it only works on specific record. Thank you in advance for any help
provided.


If CheckBoxName = True Then
LabelName.ForeColor = vbYellow
Else
LabelName.ForeColor = vbBlack
End If
 
K

Ken Snell \(MVP\)

Change the label to a textbox, and change the properties of the textbox to
make it look like a label. Be sure to set its Enabled property to No and its
Locked property to Yes. To show the text that the original label has as the
caption, use this expression as the control source of the textbox:
="put the label caption text here"

Then use Conditional Formatting for that textbox to change the Font color
(ForeColor) as you desire.
 
M

Marshall Barton

TotallyConfused said:
The example below works. but it stays yellow for all records. I need it
only to turn yellow if checked on a specific record. How do I write this so
that it only works on specific record. Thank you in advance for any help
provided.


If CheckBoxName = True Then
LabelName.ForeColor = vbYellow
Else
LabelName.ForeColor = vbBlack
End If


That should work if the form is in single view. However, if
the form is in continuous or datasheet view, you should not
use code to set a control's formatting properties because of
the problem you are seeing.

Instead, you need to change the label to a locked text box
and use Conditional Formatting on the Format menu.
 

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