Change label color

  • Thread starter Thread starter Wayne
  • Start date Start date
W

Wayne

Hi
I have a report with several check boxes. I want the label
for the check box to change color if the box is ticked. I
am using the following code:
If Me.DDNoticeOfProgressComplete = True Then
Me.DDNoticeOfProgressComplete_Label.ForeColor = vbRed
Me.DDNoticeOfProgressComplete_Label.BackStyle = 1
Else
Me.DDNoticeOfProgressComplete_Label.ForeColor = vbWhite
Me.DDNoticeOfProgressComplete_Label.BackStyle = 0
End If

But it says "You entered an expression that has no value".
Can anyone help me with this little problem?
 
In what event have you placed this code? It belongs in the Format event of
the section that contains the controls.

What is DDNoticeOfProgressComplete? Is it a control that can have a value?

If you are using Access 2000 or later, it would be much more efficient to
change DDNoticeOfProgressComplete_Label into a text box, and using
Conditional Formatting to set the color. (Format menu in report design
view.)
 
I have placed the code in the On Open event of the report.
DDNoticeOfProgressComplete is the name of the check box
field in the query that the report is using.
What I want to do is make the
DDNoticeOfProgressComplete_Label one color if the check box
is ticked and another color if it is not.
I am using Access 2000.
 
The Open event is too early. The check box has no value at that time, since
the report's RecordSource has not been loaded yet. Use the Format event of
the section that contains the check box.

Conditional formatting would be better still.
 
1. Open the report in design view.

2. Select the control to be formatted.

3. Choose Conditional Formatting from the Format menu.

4. Set Condition 1 to "Expression Is"

5. Place an expression in the box beside. Example:
[MyNumber] > 10

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Shane Andrews said:
How can I set conditional formatting on a control, based on the value of
another control?
 
Back
Top