Clearing a Form Controls background color when there is data in the cell

On a form which has all of its  text controls  background color set to 14155775, I would like code that would be called for each form controls  "on exit event", which would change the backcolor to normal if the field has had some data entered into it else leave it as 14155775.

Many thanks.

PeterWhitts
LVL 1
PeterWhittsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leigh PurvisDatabase DeveloperCommented:
You mean...

sub UpdateColour()

dim ctl as Control
ctl  = Me.ActiveControl

With ctl  
    If not isnull(.Value) Then
       .backcolor = -2147483643
    End If
End With

Set ctl = nothing
End Sub

Calling UpdateColour as you exit each control
PeterWhittsAuthor Commented:
Thanks for that but...

On tabbing through the first control which has text in, I get a rte 91 "Object variable or With Block variable not set...debug goes to ctl  = Me.ActiveControl   where Me.ActiveControl    = the text in the field and ctl = nothing?
Leigh PurvisDatabase DeveloperCommented:
Doh - damn air code...

Set ctl  = Me.ActiveControl
 ^---------- vital

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PeterWhittsAuthor Commented:
Thats great...thanks very much

sub UpdateColour()

dim ctl as Control
Set ctl  = Me.ActiveControl

With ctl  
    If not isnull(.Value) Then
       .backcolor = -2147483643
    End If
End With

Set ctl = nothing
End Sub

Calling UpdateColour as you exit each control
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.