Changing text box colors

A

Antney

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
 
A

Antney

It looks like I forgot that, can you help me out?

I'm still learning with VBA, thanks!
 
D

Douglas J. Steele

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

Private Sub Form_Current()

Call lblColor()

End Sub
 
Top