Change the color of a field on a form based on criteria

Posted on 2012-08-17
Last Modified: 2012-08-17
The attached has a form called "frmProperty"

The main form contains a field called "units" that represent the total units in the building. So for the first property, that field says the building has 40 units.  

The subform "subfrmVacyUnits" totals the number of "units by type" in the form footer.  That field is called "SumUnitNo."  In the first property, the units by type total 33.

Based on the above, we are missing 7 more units.

I would like the field in the subform "SumUnitNo"   to turn bright yellow (or whatever color) if the "SumUnitNo"  does not equal the field "units" in the building.

Is there a way to easily do this?

Question by:Patty01Access
    LVL 61

    Accepted Solution

    Use conditional formatting:

    - Right click the textbox in your subform and select Conditional Formatting...
    - Set the conditional formatting for the field value

    <> Forms!FrmProperty!Units

    - Select Yellow for the background color for that condition

    Author Closing Comment

    Great!  Never knew that existed, and how powerful it can be.

    Thanks much mbizup!
    LVL 61

    Expert Comment

    Its a great feature!

    In Access 2003 (since you're using a .mdb file), you can apply up to three different conditions/formats per control.

    In Access 2010, you can use up to 50 different conditions per control, which is way more than you'll ever reasonably need :-)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now