Text colour on a form

  • Thread starter Thread starter Box 666
  • Start date Start date
B

Box 666

I have an unbound text box, with a simple Iif statement to give a "Yes" or
"No".

I would like this to stand out by having the text green for "yes" and red
for "no" - or if this is not possible can I change the background colour of
the text box as above.

How is the best way to achieve this.

Bob
 
I have an unbound text box, with a simple Iif statement to give a "Yes" or
"No".

I would like this to stand out by having the text green for "yes" and red
for "no" - or if this is not possible can I change the background colour of
the text box as above.

How is the best way to achieve this.

Bob

Depends upon which version of Access you have.
In Access 2000 or newer:
Click on the control.
Then format + Conditional formatting
Set the Condition1 Drop-down to
Field Value is
Then select Equal to in the box alongside.
In the box alongside write "Yes"
Select the Font color (and/or the BackColor) for when the condition is
met as well as when it is not met (the Default setting).

For Access 97, using single view form, this can also be done, but you
must use code.
Post back if that's what you need.
 
Using 2000, but thank you for the offer.

Bob


fredg said:
Depends upon which version of Access you have.
In Access 2000 or newer:
Click on the control.
Then format + Conditional formatting
Set the Condition1 Drop-down to
Field Value is
Then select Equal to in the box alongside.
In the box alongside write "Yes"
Select the Font color (and/or the BackColor) for when the condition is
met as well as when it is not met (the Default setting).

For Access 97, using single view form, this can also be done, but you
must use code.
Post back if that's what you need.
 
In the Change Event of the Text Box write the following code:

Private Sub txtAnswer_Change()
If txtAnswer.Text = "Yes" Then
txtAnswer.BackColor = vbGreen
ElseIf txtAnswer.Text = "No" Then
txtAnswer.BackColor = vbRed
Else
txtAnswer.BackColor = vbWhite
End If
End Sub

You might need to replace txtAnswer with the name of your text box.
 
Back
Top