Change Fore Color in text box

P

Phillip

Hi,
I have a form with a text box and a drop down box. From the drop down box I
want to select a color and based on the color selected I want the text (Fore
Color) in the text box to change to the color selected. The drop down box is
called selectcolor and the text box is called title.
Can someone tell me how to do this?
Thanks in advance.
 
P

Phillip

Thanks Daryl, that's just what I needed.

Daryl S said:
Phillip -

In the OnClick event of your drop down box, put this control:

Me.title.forecolor = Me.selectcolor.column(0)

This sill work if your drop-box is based on a table with the color number in
the first column and the description in the second column. You can hide the
first column by setting the first column width to zero.

You could also convert the color name to the proper constants within your
drop-box click event, something like this:

Private Sub selectcolor_Click()

Dim nbrColor As Long

Select Case Me.selectcolor.Column(0)
Case "Red"
nbrColor = vbRed
Case "Blue"
nbrColor = vbBlue
Case "Green"
nbrColor = vbGreen
Case "Black"
nbrColor = vbBlack
Case Else
nbrColor = vbBlack
End Select

Me.title.forecolor = nbrColor

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top