From: Phillip on
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.

From: Daryl S on
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

--
Daryl S


"Phillip" wrote:

> 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.
>
From: Phillip on
Thanks Daryl, that's just what I needed.

"Daryl S" wrote:

> 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
>
> --
> Daryl S
>
>
> "Phillip" wrote:
>
> > 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.
> >