John... Visio MVP said:
Is there a way to set a label's colour to Red in a User Form so that
it can be used as an error message and stand out?
John... Visio MVP
The statement you're looking for is
myLabel.ForeColor = RGB(255, 0, 0) ' red
You might want to combine that with
myLabel.Font.Bold = True
There are a few ways to handle this.
- If the label should be visible and red whenever the userform is shown
(i.e., the userform is shown only when the error occurs), just set the
label's ForeColor property in the Properties pane in design mode. No extra
code is needed.
- If the label should be red whenever it appears, but it appears only when
the error occurs, then set the ForeColor in the Properties pane and also set
its Visible property to False; then toggle Visible to True in the error
handler.
- If the label should appear all the time, but you want to change the color
to red when it indicates an error, then use the above code in the error
handler. If you need to change it back to black later, set .ForeColor =
RGB(0, 0, 0).
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.