Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Home > TechHelp > Directory > Access > VBA to Change Control Backcolor by Rupert Bennett >
Back to Access TechHelp    Comments List
Upload Images | @Reply | Bookmark | Link | Email | Next Unseen |
VBA to Change Control Backcolor
Rupert Bennett 
     
3 days ago
Hello,
I am asking for help with getting my TextBoxes and ComboBoxes change to a different Backcolor on GotFocus and change back to its original Backcolor on LostFocus. Maybe a global routine to set these, or do this when the form opens / loads.
I am getting this done now by coding the gotFocus and LostFocus Events for each control, but it is very time consuming when you have many controls on the form and also have many forms. Any help would be greatly appreciated and thanks in advance for your help.
Donald Blackwell  @Reply  
        
3 days ago
Have you tried Conditional Formatting

Select the field has focus option for your preferred adjustment and then it automatically should revert to it's default when it loses focus
Richard Rost  @Reply  
           
3 days ago
Donald pointed you to the right feature, Rupert. In Design View, select your text boxes and combo boxes, go to Format > Conditional Formatting, and add a Field Has Focus rule with the background color you want. When you tab or click out of the control, the highlight goes away. No Got Focus or Lost Focus code needed for that.

You can apply the rule to several controls at once if they don't already have rules you want to keep. If a control already has conditional formatting, add the focus rule to that control separately. My Conditional Formatting video shows both setups, including how to give the focus rule priority.
Rupert Bennett OP  @Reply  
     
3 days ago
Saying thank you is not enough to express my gratitude for your assistance. This works perfectly and is much easier than VBA coding. Thank you.
Richard Rost  @Reply  
           
3 days ago
You're very welcome, Rupert. Glad that did the trick! Conditional Formatting is one of those little Access features that can save you a lot of repetitive VBA. Plus, it works in continuous forms, so you can have different controls showing different colors and such. That's not nearly as easy to do with VBA events like it is on a single form.
Add a Reply Upload an Image
Next Unseen

 
 
What's This?

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 11/27/2026 1:09:40 AM. PLT: 1s