Best way to test a MS Access application?

calendar_today Asked Sep 6, 2008
thumb_up 17 upvotes
history Updated April 14, 2026

Direct Answer

I appreciated knox's and david's answers. My answer will be somewhere between theirs: just make forms that do not need to be debugged! I think that forms should be exclusively…. This is a 7-line VBA Core snippet, ranked #12th of 95 by community upvote score, from 2008.


The Problem (Q-score 32, ranked #12th of 95 in the VBA Core archive)

The scenario as originally posted in 2008

With the code, forms and data inside the same database I am wondering what are the best practices to design a suite of tests for a Microsoft Access application (say for Access 2007).

One of the main issues with testing forms is that only a few controls have a hwnd handle and other controls only get one they have focus, which makes automation quite opaque since you cant get a list of controls on a form to act on.

Any experience to share?

Why community consensus is tight on this one

Across 95 VBA Core entries in the archive, the accepted answer here holds solid answer (above median) status — meaning voters are unusually aligned on the right fix.


The Verified Solution — solid answer (above median) (+17)

7-line VBA Core pattern (copy-ready)

I appreciated knox’s and david’s answers. My answer will be somewhere between theirs: just make forms that do not need to be debugged!

I think that forms should be exclusively used as what they are basically, meaning graphic interface only, meaning here that they do not have to be debugged! The debugging job is then limited to your VBA modules and objects, which is a lot easier to handle.

There is of course a natural tendency to add VBA code to forms and/or controls, specially when Access offers you these great “after Update” and “on change” events, but I definitely advise you not to put any form or control specific code in the form’s module. This makes further maintenance and upgrade very costy, where your code is split between VBA modules and forms/controls modules.

This does not mean you cannot use anymore this AfterUpdate event! Just put standard code in the event, like this:

Private Sub myControl_AfterUpdate()  
    CTLAfterUpdate myControl
    On Error Resume Next
    Eval ("CTLAfterUpdate_MyForm()")
    On Error GoTo 0  
End sub

Where:

  • CTLAfterUpdate is a standard procedure run each time a control is updated in a form

  • CTLAfterUpdateMyForm is a specific procedure run each time a control is updated on MyForm

I have then 2 modules. The first one is

  • utilityFormEvents
    where I will have my CTLAfterUpdate generic event

The second one is

  • MyAppFormEvents
    containing the specific code of all specific forms of the MyApp application
    and including the CTLAfterUpdateMyForm procedure. Of course, CTLAfterUpdateMyForm
    might not exist if there are no specific code to run. This is why we turn the
    “On error” to “resume next” …

Choosing such a generic solution means a lot. It means you are reaching a high level of code normalization (meaning painless maintenance of code). And when you say that you do not have any form-specific code, it also means that form modules are fully standardized, and their production can be automated: just say which events you want to manage at the form/control level, and define your generic/specific procedures terminology.
Write your automation code, once for all.
It takes a few days of work but it give exciting results. I have been using this solution for the last 2 years and it is clearly the right one: my forms are fully and automatically created from scratch with a “Forms Table”, linked to a “Controls Table”.
I can then spend my time working on the specific procedures of the form, if any.

Code normalization, even with MS Access, is a long process. But it is really worth the pain!


When to Use It — vintage (14+ years old, pre-2013)

Ranked #12th in its category — specialized fit

This pattern sits in the 86% tail relative to the top answer. Reach for it when your scenario closely matches the question title; otherwise browse the VBA Core archive for a higher-consensus alternative.

What changed between 2008 and 2026

The answer is 18 years old. The VBA Core object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.

help
Frequently Asked Questions

Is this above-median answer still worth copying?
expand_more

Answer score +17 vs the VBA Core archive median ~5; this entry is solid. The score plus 32 supporting upvotes on the question itself (+32) means the asker and 16 subsequent voters all validated the approach.

Does the 7-line snippet run as-is in Office 2026?
expand_more

Yes. The 7-line pattern compiles on Office 365, Office 2024, and Office LTSC 2026. Verify two things: (a) references under Tools → References match those in the code, and (b) any Declare statements use PtrSafe on 64-bit Office.

This answer is 18 years old. Is it still relevant in 2026?
expand_more

Published 2008, which is 18 year(s) before today’s Office 2026 build. The VBA Core object model has had no breaking changes in that window. Three things to re-test: (1) blocked macros on downloaded files (Mark-of-the-Web), (2) 64-bit API declarations (PtrSafe, LongPtr), (3) any shift toward Office Scripts for web scenarios.

Which VBA Core pattern ranks just above this one at #11?
expand_more

The pattern one rank above is “Installing Office Customization”. If your use case overlaps, compare both before committing.

Data source: Community-verified Q&A snapshot. Q-score 32, Answer-score 17, original post 2008, ranked #12th of 95 in the VBA Core archive. Last regenerated April 14, 2026.

vba