Fix Microsoft Access Error 7966 When Adding Conditional Formatting Rules
Question details
The user encounters Error 7966 in Microsoft Access when attempting to add or modify a fourth conditional formatting rule using a VBA script.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Creating or modifying the fourth conditional formatting rule (FormatConditions index 3) in an Access database via VBA.
- Observed behavior
- Access triggers Error 7966 when the VBA script tries to execute the Modify method on the FormatConditions collection.
Verify that your Microsoft Access application is fully updated to the latest build and create a backup of your ACCDB database before modifying any VBA modules.
Verify Rule Index and Add Conditions Directly
Ensure the VBA code points to the correct FormatConditions index and add new rules directly to the collection instead of modifying non-existent ones.
In Microsoft Access, older versions limited controls to a maximum of three conditional formatting rules. Modern ACCDB databases support more, but legacy property limitations can sometimes trigger Error 7966 if VBA references an incorrect index or tries to modify a rule that hasn't been instantiated.
Since the FormatConditions collection is zero-based, the fourth rule corresponds to index 3.
Open your VBA editor and locate the conditional formatting script. Confirm that you are correctly referencing the fourth rule using `ctl.FormatConditions(3)`.
Before calling the `Modify` method, ensure the condition actually exists. If it does not, use the `FormatConditions.Add` method directly instead of trying to modify an empty index.
Click 'Debug' > 'Compile' in the VBA editor to check for syntax errors. Once cleared, save the module and run the script again.

Isolate the Issue in a New ACCDB File
Testing the formatting script in a brand new database helps determine if the original file retains hidden legacy limitations or corruption.
Looking for a Lightweight and Free Office Suite?
While WPS Office does not include a relational database application like Microsoft Access, it offers a robust, completely free, and highly compatible alternative for Word, Excel, and PowerPoint files. If you frequently manage data and conditional formatting in spreadsheets, WPS Spreadsheet provides powerful data analysis tools and familiar VBA support without the steep cost.
- 1. Download WPS Office: Visit the official WPS website and download the free installer for your operating system.
- 2. Install the Suite: Run the downloaded installer and follow the on-screen prompts to complete the setup in minutes.
- 3. Open Your Office Files: Launch WPS Office and directly open your existing .xlsx, .docx, or .pptx files seamlessly.

Frequently Asked Questions
Why does Microsoft Access limit me to three conditional formatting rules?
Older versions of Microsoft Access (Access 2007 and earlier) had a strict limit of three conditional formatting rules per control. While modern ACCDB formats (Access 2010 and later) allow up to 50 rules, running databases in legacy compatibility modes or using outdated MDB formats will still trigger limitations and errors.
What is the correct syntax to modify the fourth conditional formatting rule in VBA?
Because the `FormatConditions` collection is zero-based, the fourth rule is accessed using index 3. Ensure the rule has been added to the collection before executing `ctl.FormatConditions(3).Modify acExpression, acEqual, ExprStr`.
How do I check my current Microsoft Access build version?
Open Microsoft Access, click on the 'File' tab, and select 'Account' (or 'Help' in older versions). Look under 'Product Information' to view your current Version, Build number, and architecture (32-bit or 64-bit).




