A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Change Fore Color in text box



 
 
Thread Tools Display Modes
  #1  
Old April 5th, 2010, 03:30 PM posted to microsoft.public.access.forms
Phillip
external usenet poster
 
Posts: 63
Default 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  
Old April 5th, 2010, 04:33 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default 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  
Old April 5th, 2010, 05:26 PM posted to microsoft.public.access.forms
Phillip
external usenet poster
 
Posts: 63
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.