Change color of records in text box

  • Thread starter Thread starter ChuckL
  • Start date Start date
C

ChuckL

I have a form in which I am displaying multiple records.
Each record can either be a "Yes" or "No". Can I have the
BackColor of the records with "Yes" turn Red and the
BackColor of the records with "No" turn Green? I used the
following code (below) and, because one of my records
displays "Yes" they all turn Red - including the "No"s.

Thanks Much!!

Private Sub Form_Current()

' If value in text boxes say yes then the back color
' of the text box will turn red, otherwise it will
turn green
If (Me!FinishedbutnotreviewedSNROs) = "Yes" Then
Me!FinishedbutnotreviewedSNROs.BackColor = 255

' Otherwise, display value as green
Else
Me!FinishedbutnotreviewedSNROs.BackColor = 4259584
End If

End Sub
 
I have a form in which I am displaying multiple records.
Each record can either be a "Yes" or "No". Can I have the
BackColor of the records with "Yes" turn Red and the
BackColor of the records with "No" turn Green? I used the
following code (below) and, because one of my records
displays "Yes" they all turn Red - including the "No"s.

Thanks Much!!

Private Sub Form_Current()

' If value in text boxes say yes then the back color
' of the text box will turn red, otherwise it will
turn green
If (Me!FinishedbutnotreviewedSNROs) = "Yes" Then
Me!FinishedbutnotreviewedSNROs.BackColor = 255

' Otherwise, display value as green
Else
Me!FinishedbutnotreviewedSNROs.BackColor = 4259584
End If

End Sub

Your code will not work in forms continuous view.
I'll assume this is a text field, not a Yes/No number field.

If you have Access 2000 or later you can use the control's Conditional
Formatting property.

In Design View select the control. Then,
Format + Conditional Formatting
Set the Condition 1 to
Value Is = "Yes"

Select the color wanted for both the default and if the condition is
met.
 
Back
Top