Others

Use Conditional Formatting in Microsoft Access Forms with VBA

Ayan MasoodAyan Masood Nov 22, 2026 868 views

Question details

Apply background colors to an Access form control based on text contained in a field value.

Use Conditional Formatting in Microsoft Access Forms with VBA
Product
Microsoft Access
Device & OS
not provided
Scenario
A form displays concatenated status values, and the user wants Resolved values to appear green and Active values to appear yellow.
Observed behavior
The desired colors should be applied to the form control for each record, rather than to the recordset field.
Before you start

Open the form in Design View and identify the name of the status field and its bound text box. The examples below use a field named Status and a text box named txtStatus; replace these names with your own.

Solution 1Recommended

Create conditional formatting rules for the status control

Use the form designer to color the control without writing VBA code.

1
Select the control

Open the form in Design View and select the text box bound to the Status field.

2
Add the Resolved rule

On the Format tab, select Conditional Formatting, then New Rule. Choose an expression-based rule and enter InStr(1, Nz([Status], ""), "resolved", 1) > 0. Set the background color to green.

3
Add the Active rule

Select New Rule again and enter InStr(1, Nz([Status], ""), "active", 1) > 0. Set the background color to yellow.

4
Save and test

Save the form and open it in Form View. Check records containing Resolved or Active to confirm that the text box displays the expected color.

Create conditional formatting rules for the status control
Overlapping values: If a value contains both words, both rules can match. Arrange the rules in the Conditional Formatting Rules Manager so the intended rule has priority.
Free Microsoft Office alternative

Use WPS Office for compatible documents and spreadsheets

WPS Office is a free, lightweight alternative with a familiar interface for working with documents and spreadsheets. Its Microsoft Office format compatibility makes it easy to move existing files, although it does not replace Access form controls or fix Access VBA.

Use spreadsheet formatting to highlight status values in tabular data.Open and edit Microsoft Office formats such as DOCX, XLSX, and PPTX.Work in a familiar interface that makes migration easier.Use a free, lightweight suite for everyday office tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Can I set a recordset field's background color directly?

No. A recordset field stores data; background color is a property of the form control displaying it. Apply conditional formatting to that control instead.

How can I match a status word inside a longer string?

In a conditional formatting expression, use InStr with a text comparison, such as InStr(1, Nz([Status], ""), "resolved", 1) > 0. Replace Status with your field name.

What happens if a value contains both Resolved and Active?

Both expressions can match. Open Conditional Formatting from the form's Format tab and arrange the rules so the intended color has priority.

Why does the VBA example delete existing rules?

Me.txtStatus.FormatConditions.Delete clears the control's rules before adding new ones, preventing duplicates when the form loads. Remove or adapt that line if other rules must be retained.