I have a input field that allows the user to enter the color he wants to define for text. What I want to do is, afte the using enters, let say WHITE, I want to display some label I have defined with the current color.
Example:
Input color: White
label_font: Sample text (I want on lost focus to display the text in white)
Thanks for the help
scottk
11-02-2001, 08:49 AM
I assume that the color is entered into a text box. With this assumption place this code in the "after update" event of the text box.
Private Sub ColorBox_AfterUpdate()
On Error GoTo Err_ColorBox_AfterUpdate
Dim strColor As String
If Me.ColorBox = "White" Then
strColor = 16777215
Else
If Me.ColorBox = "Red" Then
strColor = 255
Else
If Me.ColorBox = "Yellow" Then
strColor = 65535
Else
If Me.ColorBox = "Blue" Then
strColor = 16711680
Else
MsgBox "You must enter Red, White, Yellow or Blue"
End If
End If
End If
End If
Me.lblChanging.ForeColor = strColor
Err_ColorBox_AfterUpdate:
Resume Exit_ColorBox_AfterUpdate
Exit_ColorBox_AfterUpdate:
Exit Sub
End Sub
Just change any occurrance of the ColorBox to the name of your text box and change lblChanging to the name of your label.
Thank you Scott, I know this will be helpful
Jim