change color of several text boxes

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!
 
W

Wayne-I-M

You can set the background colour

if me.[textbox1]="ABC" then
me.[textbox1].background=vbYellow
else
me.[textbox1].background=vbWhite
end if
 
C

Chad

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
 

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