Excuse the real newbie question, but:
I'd like to set the background colour of a text field using VBA. (ie. (colour dependant on what's entered). 'Fraid I barely know where to start.
Help, please?!
Thanks
Excuse the real newbie question, but:
I'd like to set the background colour of a text field using VBA. (ie. (colour dependant on what's entered). 'Fraid I barely know where to start.
Help, please?!
Thanks
Is this in a form control or a table itself? If you mean the table when opened in datasheet view, then there is no such thing. If a textbox on a form, then I believe Me.TxtBoxName.BackColor property should work out for you.
Thanks very much for your replies. I've taken a look, and had a further think about what I'm trying to achieve. And I think it's not quite as per my initial post. :/
I have a form, on which I have three fields (let's call them field1, field2 and field3). field3 is a combo-box, with five options (let's call them option1, option2, option3, option4, option5). I'm wondering whether, if I use a text field (field4) as a background to (all together) field1, field2 and field3, I can set the background to turn black when option5 is chosen.
If I can get the above functionality to work as required on this particular form, I'd like to apply it to some other forms.
Again, sorry for the completely newbie nature of my query. I'd be very grateful for any help offered. Thank you.
mmm, I'm still not making any progress with this. :/ Can't be that difficult, can it
Use the rectangle control to make background colors. Draw it the size you want to include all the fields you want. Use this in your code to change the color. Make sure to send it to the back.
In the AfterUpdate event of the field in question: if field="xxx" then rectangle.backgroundcolor="#111111" else... etc
Thanks, I must confess I hadn't thougt of using 'rectangle'. However, I think as I'm v new to VBA, I'm making other mistakes, WHATEVER methid I try. Excuse my VBA ignornace, but could you provide the entire block of code I need to use, please? Thank you very much.
In the AfterUpdate event of field3
If me!field3.column(n) = "x" then
(note - columns start from 0 so the first column is number 0; column 0 is the default so you can leave it out)
me!rectangle.backcolor="#111111"
else
me!rectangle.backcolor="#222222"
endif
Note - layout the code as per your own way - tabbing, etc
Note - you can also use me!rectangle.visible=true(false)
Note - remember to do the Send to Back for the rectangle so that you can see the text fields