How to Change an Access Control BackColor with a VBA Module
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.
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.
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.
In Microsoft Access, open the database and press Alt+F11 to open the Visual Basic for Applications editor.
Go to Insert > Module to create a new standard module.
Paste the following code into the module: Function ChangeColor(ctrl As Control) ctrl.BackColor = RGB(255, 153, 0) End Function
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.
Switch to Form View and click the button. The referenced control should change to orange.
Color a Control Based on a Value with Form Events
Use this approach when the background should change after a value changes, such as when a number exceeds 100.
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. 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. 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. 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.

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.




