Tips for conditional formatting in Access

Applies to
Microsoft Access 2000

ShowConditional formatting with controls that contain expressions

You might see unexpected results when you apply conditional formatting to a control that already contains an expression. To ensure that a control containing an expression is formatted correctly, click Expression Is instead of Field Value Is, and use the expression itself in the condition.

For example, suppose a control contains the following expression:


To highlight the control when it contains a value greater than $50.00, apply the following condition to the control:

Expression Is [Subtotal]+[Freight] > 50

ShowSpecifying when a control is enabled

Conditional formatting provides an easy way to make a control unavailable - you can prevent the value it contains from being changed if a specified condition is true.

By default, a control is enabled. To specify that a control is not enabled when the condition is true, click the Enabled button (the rightmost button in the Conditional Formatting dialog box). For example, you can make the UnitsOnOrder control unavailable if the value of the Discontinued field is Yes by selecting the UnitsOnOrder control and applying the following condition:

Expression Is [Discontinued]=Yes

Condition that specifies UnitsOnOrder is not enabled if the Discontinued field is Yes

Note that the Enabled button is pressed in under Default Formatting, but is not pressed in under Condition 1.

ShowMonitoring values in a field that contains dates

If you have a field that contains dates, you can use conditional formatting to monitor the values in that field.

For example, you can highlight an overdue item or an upcoming deadline by using the Date() function in your condition. The Date() function returns the current system date - the current date according to your computer. The expression Date()+7 returns the date that falls seven days from today.

To highlight overdue items, apply the following condition to the control that contains date values:

Field Value Is less than Date()

To highlight an item that is due within a week, apply the following condition to the control:

Field Value Is between Date() and Date()+7

For more examples of expressions that calculate dates in forms and reports, type examples of expressions in the Office Assistant or on the Answer Wizard tab in the Help window, and then click Search.

For more information about expressions that calculate dates, see the following article in the Microsoft Knowledge Base:

ACC2000: Functions for Calculating and Displaying Date/Time Values.