View Full Version : Conditional formatting from checkbox


82412
02-02-2008, 10:26 AM
In one of my forms I have used this code in the properties of a check box (with the names changed) to apply conditional formatting to a text box when the checkbox is ticked:


Private Sub Check14_AfterUpdate()
If Me!Check14 = True Then
Me!txtDesc.BackColor = vbRed
Me!txtDesc.ForeColor = vbBlack
Else
Me!txtDesc.BackColor = vbWhite
Me!txtDesc.ForeColor = vbRed
End If
End Sub



It works perfectly, except that when I apply a change to one record the same colour change is applied to all records in the form regardless of whether or not the checkbox has been ticked. What am I missing?

RuralGuy
02-02-2008, 10:33 AM
It sounds like you have a continuous form. Use Conditional formatting on the txtDesc control if the CheckBox is a bound control.

boblarson
02-02-2008, 10:36 AM
And by Conditional Formatting, RG is saying to select the txtDesc box and in design view go to the menu bar and select Format > Conditional Formatting. You would need to use the Expression Is instead of Value Is from the drop down.

82412
02-06-2008, 01:58 PM
Thanks guys, sorry for the late reply, been off with flu. Problem Sorted.