Changing text box colors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a text box where I want to change the backcolor depending on the name
in the text box. For example, if the text box reads "red", then the backcolor
should turn red.

I came up with this, but it doesn't seem to work. Can anyone help? Thanks.

Option Compare Database


Private Sub lblColor()

Dim lblColor As String

If Me.lblColor = "Red" Then
Me.lblColor.BackColor = vbRed
ElseIf Me.lblColor = "Orange" Then
Me.lblColor.BackColor = vbWhite

End Sub
 
In the form's Current event, call the routine you wrote:

Private Sub Form_Current()

Call lblColor()

End Sub
 
Back
Top