From: Phillip on 5 Apr 2010 10:30 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 5 Apr 2010 11:33 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 5 Apr 2010 12:26 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. > >
|
Pages: 1 Prev: How do you put an "&" sign on a button? Next: Full Screen Forms in 2007 |