Others

How to Change an Access Control BackColor with a VBA Module

Amos GikundaAmos Gikunda Nov 13, 2026 869 views

Question details

The user wants to change a Microsoft Access form control background color through VBA code, either based on a value condition or from a button click.

Product
Microsoft Access
Device & OS
not provided
Scenario
The user is working in Microsoft Access and wants to use a standard VBA module to set a form control's BackColor, either when a button is clicked or when a value exceeds a threshold.
Observed behavior
The desired outcome is that the referenced control's BackColor updates to RGB(255, 153, 0) or toggles between orange and white based on the VBA logic.
Before you start

Open the Access database in Design View, confirm the exact form and target control names, and enable VBA macros so the module code can run.

Solution 1Recommended

Create a Standard VBA Module to Set Access Control BackColor

Use this method when you want reusable code that can be called from a button click or form event.

A standard module keeps the color-change logic separate from the form, so it can be reused across controls and forms.

1
Open the VBA editor

In Microsoft Access, open the database and press Alt+F11 to open the Visual Basic for Applications editor.

2
Insert a standard module

Go to Insert > Module to create a new standard module.

3
Add the ChangeColor function

Paste the following code into the module: Function ChangeColor(ctrl As Control) ctrl.BackColor = RGB(255, 153, 0) End Function

4
Call the function from a button

In form Design View, select the button, open the Property Sheet, go to the Event tab, and set On Click to =ChangeColor([Form].[ControlName]). Replace ControlName with the actual control name.

5
Test the color change

Switch to Form View and click the button. The referenced control should change to orange.

Use exact control names: Replace ControlName in the On Click expression with the actual control name from the Property Sheet, or Access will display a syntax error.
Free Microsoft Office alternative

Use WPS Office as a Free Microsoft Office Alternative for Everyday Document Tasks

Microsoft Access VBA is specific to Microsoft Access, and WPS Office does not include an Access database replacement. For everyday document work, WPS Office is a free, lightweight, easy-to-use alternative that opens and edits .docx, .xlsx, and .pptx files in a familiar Office interface, making migration simple.

  1. 1. Download WPS Office: Get the free WPS Office installer from the official WPS website and install it on your Windows, macOS, Linux, Android, or iOS device.
  2. 2. Open your Microsoft Office files: Launch WPS Office and use File > Open to open .docx, .xlsx, or .pptx files. The ribbon-style interface keeps common Office commands familiar.
  3. 3. Continue editing and save in Microsoft formats: Edit the document and save it back to the original .docx, .xlsx, or .pptx format, or export to PDF as needed.
Free, lightweight Office suite with a familiar ribbon-style interfaceStrong compatibility with Microsoft Word, Excel, and PowerPoint file formatsOpens and saves .docx, .xlsx, and .pptx files without a paid Microsoft 365 subscriptionEasy migration for everyday Office document tasks when Microsoft Access is not requiredIncludes PDF conversion and simple sharing tools for common document workflows
microsoft office alternative - wps office

Frequently Asked Questions

Can I run this Access VBA BackColor code in WPS Office?

No. WPS Office does not include Microsoft Access or the Access VBA object model. Use this code in Microsoft Access, and use WPS Office for Word, Excel, and PowerPoint documents.

Why does the BackColor change appear on every row in a continuous form?

VBA sets the BackColor property for the control itself, so all rows show the same color. To color each row independently, select the control in Design View, go to the Format tab, and use Conditional Formatting with a rule such as Field Value Is > 100.

How do I call a standard module function from an Access button?

Open the form in Design View, select the button, open the Property Sheet, go to the Event tab, and set the On Click property to =ChangeColor([Form].[ControlName]). Replace ControlName with the actual control name.

What RGB value is orange in this example?

The example uses RGB(255, 153, 0), which produces orange. To use white, set the BackColor to RGB(255, 255, 255).

Does WPS Office support Microsoft Access database files?

WPS Office does not provide a Microsoft Access database application. It is designed for Word, Excel, PowerPoint, and PDF-compatible document workflows.