If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Change Fore Color in text box
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. |
#2
|
|||
|
|||
Change Fore Color in text box
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. |
#3
|
|||
|
|||
Change Fore Color in text box
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. |
Thread Tools | |
Display Modes | |
|
|