Cat On A Spreadsheet
When Excel projects scale beyond single-user workbooks and move into operational reporting + automation roles, the number one major maintainability problem that appears is how teams handle database access. Most Excel VBA scripts end up with connection strings embedded in 40 different modules, SQL scattered everywhere, and mixed usage of ADO and DAO depending on who last edited the macro. That is not maintainable long term — and it absolutely breaks the minute IT migrates Access to SQL Server or SQL Server to Azure SQL.
This post shows you how to architect a reusable database access module in VBA that abstracts away the underlying DB engine, so your “business logic” code never directly touches DAO or ADO again. The result is that changing database vendor becomes a one-module edit — instead of rewriting every procedure in your workbook.
We want a single module responsible for all DB interactions.
You set the DB type (SQL Server or Access)
You set the ConnectionString
All query calls go through one unified function
Your VBA code does not know or care what DB engine is behind it — it simply calls RunQuery("SELECT ...") and receives back a Recordset object.
This is actual maintainable architecture.
SQL Server:
Access:
This is the difference between script automation and software architecture. When your company migrates from Access → SQL Server — which they eventually will — you do not rewrite every reporting macro. You simply adjust the ConnectionString in one location. And if someone in the future wants to plug in SQLite or another provider — this module is the place where that can be added without touching any business logic. This is the pattern that makes VBA scalable inside corporate ecosystems.
Cat On A Spreadsheet