?
Solved

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

Posted on 2012-08-17
3
Medium Priority
?
542 Views
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?

Thanks!
ChangeFieldColor.mdb
0
Comment
Question by:Patty01Access
  • 2
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 38306503
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
ChangeFieldColor.mdb
0
 

Author Closing Comment

by:Patty01Access
ID: 38306510
Great!  Never knew that existed, and how powerful it can be.

Thanks much mbizup!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38306526
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 :-)
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
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 …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

850 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