background color problem in an access form
I have a form containing a textbox "Text20". I have put some code in the OnCurrent event of the form:
Option Compare Database
Private Sub Form_Curr开发者_JAVA百科ent()
Text20.BackColor = vbRed
End Sub
It does nothing when I display the form whereas it should color my textbox. Do you see why ?
Thank you
There really is no reason to do this in the code behind. Just right click the control, select conditional formatting and apply the formatting and give it a condition and a format.
No code required.
In fact, the code you included in your example would re-set that every time the form changes records, which is overkill anyway.
Better yet. Why not just set the color in the property sheet for the control?
精彩评论