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

E

Eddie Camacho

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
 
F

fredg

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top