How do I change background color of Text Box based on condition?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wanted to make specific text boxes stand out by changing the background
color based on a condition (ie. if person from one Company then yellow
otherwise Green). But have not been able to. I put this Sub in the Detail
portion...

Where Info is the Textbox and Company is the company

Const WHITE = 16777215
Const YELLOW = 65535

If (Me![Company]) = "HHSC" Then

Me![Info].BackColor = YELLOW
Else
Me![Info].BackColor = WHITE
End If
 
I wanted to make specific text boxes stand out by changing the background
color based on a condition (ie. if person from one Company then yellow
otherwise Green). But have not been able to. I put this Sub in the Detail
portion...

Where Info is the Textbox and Company is the company

Const WHITE = 16777215
Const YELLOW = 65535

If (Me![Company]) = "HHSC" Then

Me![Info].BackColor = YELLOW
Else
Me![Info].BackColor = WHITE
End If

[Company]'s datatype is Text, not Number?

Code the Report Section's Format event:
If Me![Company] = "HHSC" Then
Me![Info].BackColor = vbYellow
Else
Me![Info].BackColor = vbWhite
End If

You can also use the Info control's Conditional Formatting property.
 
Back
Top