Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Override Conditional Format
Amanda McDonald 
      
4 years ago
I have fields conditionally formatted to change the background color when the fields have focus.

I also have fields that are required. The following code sends the user back to the form to enter the required fields.

If IsNull(Company) And IsNull(CoName) And IsNull(FirstName) And IsNull(LastName) Then
        MsgBox "Either First & Last Name" & vbCrLf & "OR" & vbCrLf & "Company & Short Company Name are required.", vbOKOnly, "Unable to change or save property."
        Company.SetFocus
        Company.BackColor = 14143015
        CoName.BackColor = 14143015
        FirstName.BackColor = 14143015
        LastName.BackColor = 14143015
Exit Sub

The SetFocus code and Has Focus conditional formatting override the BackColor code.

Is there a way to write it so that the BackColor overrides the Has Focus conditional formatting?
Amanda McDonald OP  @Reply  
      
4 years ago

Amanda McDonald OP  @Reply  
      
4 years ago

Amanda McDonald OP  @Reply  
      
4 years ago

Kevin Yip  @Reply  
     
4 years ago
You can't override conditional formatting like that.  But you can add a conditional format to override another.  See picture below.  Add a condition that sets a different color if IsNull() is true.  Do this for every control.  You must enclose the control names with square brackets as shown, even if they have no spaces.  And make sure this condition is at the top of the list, since it says "rules are applied in the order shown."  Use the ^ and V keys to move it up or down.  That way, the darker color will only be used if IsNull is true.  If it's not true, the "Has Focus" color is used instead.  Remove your VBA code above; you don't need it.
Kevin Yip  @Reply  
     
4 years ago

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

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: 5/6/2026 2:20:35 PM. PLT: 0s