PDA

View Full Version : How to set a color of a textbox based on a tick in a checkbox using vba?



wedd
12-22-2010, 11:43 PM
:friends: Hi, based on a checkbox on my form I would like the textbox of "venue available" to be automatically colored red, and if unchecked be automatically green. Can this be done using vba? If so, how can this be done? Do you have any examples how this can be done? In addition, if I wanted to block a venue from changing a time, can I use vba to perform this? If so, how can this be done?


Thanks for your help :friends:

Imdabaum
12-23-2010, 07:43 AM
There are two ways to do this. If the checkbox is bound to data in a table (yes/no) type then you can set a conditional format on the control (This is the my suggested method). Otherwise, you just put an event on the AfterUpdate or Click event that sets BackColor of your control to #0000000 or whatever color you choose.

Imdabaum
12-23-2010, 07:48 AM
Here is a fun little application to handle colors in Access if you need to convert your RGB into Hex or strict Access color codes.

I did not create this, but have found it useful.