• ** There has been a recent site upgrade. Please clear your browser cache to avoid issues. **
  • New forum feature - post voting and best solution

    Check out this thread for the details: https://www.access-programmers.co.uk/forums/threads/new-forum-feature-post-voting-and-best-answer.314134/

    This new feature looks great to me! :)

  • We now have 3 forum themes

    Go for the default (light) theme, Shades of Grey or Shades of Blue. I just added the Blue one.

    The thread about it is here: https://www.access-programmers.co.uk/forums/threads/new-forum-theme-shades-of-blue.314136/

Change the background color of a text box (1 Viewer)

MikiA

New member
Local time
Today, 05:20
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 ?
 

June7

AWF VIP
Local time
Yesterday, 19:20
Joined
Mar 9, 2014
Messages
3,337
It is but should use Conditional Formatting instead of VBA.

Yes, form Current sounds reasonable. Also, each textbox AfterUpdate or LostFocus event.
 

MikiA

New member
Local time
Today, 05:20
Joined
Sep 2, 2020
Messages
17
I have always viewed conditional formatting as a temporary solution
 

June7

AWF VIP
Local time
Yesterday, 19:20
Joined
Mar 9, 2014
Messages
3,337
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.
 

MikiA

New member
Local time
Today, 05:20
Joined
Sep 2, 2020
Messages
17
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

Top Bottom