change color of several text boxes

  • Thread starter Thread starter Chad
  • Start date Start date
C

Chad

Hello, I need to change the color of a text box if there is a certain letter
in it. I would use conditional formationg but you can only use 3. I have 31
text boxes and if there is a "P" in one of them I want the box to turn Blue
and if there is a "V" then it would turn green and so on. How could this be
done in VBA? thanks!
 
You can set the background colour

if me.[textbox1]="ABC" then
me.[textbox1].background=vbYellow
else
me.[textbox1].background=vbWhite
end if
 
I forgot to mention that the form has 31 text boxes on it in a row and the
form is a continious form so when it opens it will have 365 text boxes. I
tried your code and it wants to color an entire row instead of the box that
has a "P" in it. As for how many different coored boxes, well it depends on
what is entered. (Up to 12)

Thanks,
Chad
 
Back
Top