Change the background color of a text box

MikiA

New member
Local time
Today, 15:00
Joined
Sep 2, 2020
Messages
17
Hello,

I have a form and a lot of text boxes on it.
I want to change the color of the text box when the value is entered.
So, i know how to do that using conditional formating.
Also, i know how to that using after update event.....
My question is: Is it posible create a loop and check all text box on the form. If no value, back color = white, if value is there, back color = red, for example.
Something like:
Code:
Dim ctl As Control

For Each ctl In Forms!Form1.Controls
If ctl.ControlType = acTextBox .....

And where i need put that code ?
On the form current property ?

Any idea ?
 
It is but should use Conditional Formatting instead of VBA.

Yes, form Current sounds reasonable. Also, each textbox AfterUpdate or LostFocus event.
 
I have always viewed conditional formatting as a temporary solution
 
Conditional Formatting is far from a temporary solution. With VBA, all records on form will show the same settings so is not practical for continuous or datasheet. On a report, VBA would have to be in Format event which executes only for PrintPreview or direct to printer, not ReportView.
 
I understand. I will try with Conditional Formatting. Honestly, will be much for work, but result will be better i belive. Thanks for you time :)
 

Users who are viewing this thread

Back
Top Bottom