[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2006-03-28
4
Medium Priority
?
209 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:PeterWhitts
  • 2
  • 2
4 Comments
 
LVL 44

Expert Comment

by:Leigh Purvis
ID: 16311009
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
0
 
LVL 1

Author Comment

by:PeterWhitts
ID: 16311313
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?
0
 
LVL 44

Accepted Solution

by:
Leigh Purvis earned 800 total points
ID: 16311367
Doh - damn air code...

Set ctl  = Me.ActiveControl
 ^---------- vital
0
 
LVL 1

Author Comment

by:PeterWhitts
ID: 16311442
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
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question