-
Notifications
You must be signed in to change notification settings - Fork 70
Connections
The add-in stores linked-table and pass-through query connection strings in a
per-developer .env file instead of committing raw ODBC strings to source control.
Exported source files reference these entries as env:conn_* keys.
| Location | Property |
|---|---|
tbldefs/*.json |
Connect on SQL-linked tables |
queries/*.json |
Connect on pass-through queries |
db-connection.json |
Keys used to prime Access's ODBC cache during import |
During export, the add-in replaces connection strings with env:conn_*
references when UseEnvForConnections is enabled in vcs-options.json. During
import/build, each reference is resolved back to the full ODBC string from
the merged .env config.
This file does not store connection strings. It lists which env:conn_*
connections to touch during the "Importing db connections" step so Access caches
ODBC credentials once before importing dozens of linked tables.
Example:
{
"Items": {
"env:conn_mydb": {
"env:conn_mydb": "dbo_tblCustomers"
}
}
}The inner value is a linked table name used to open a temporary query against that
connection. If a referenced key is missing from .env, Access may show an ODBC
login dialog during import.
Path: {ExportFolder}/.env (gitignored).
The add-in auto-creates this file on export when connection sanitization is active. Each developer maintains their own copy with machine-specific server names and credentials.
When the add-in manages your .gitignore, it excludes *.env plus all layered
variants (.env.*) while keeping *.example templates committed:
*.env
.env.*
!.env*.example
Commit templates such as .env.example and .env.dev.example so other
developers know which keys to fill in; never commit the real .env* files.
Named connections (EnvConnectionNames in vcs-options.json) let projects use
stable keys like conn_production instead of auto-generated names.
For projects that target different backends (dev/staging/production) from the same source tree, use a selector file plus environment-specific overlays.
Load order (later overrides earlier):
-
.env— shared base config; setAPP_ENVhere -
.env.local— developer-local overrides (gitignored) -
.env.{APP_ENV}— environment-specific values (e.g..env.dev) -
.env.{APP_ENV}.local— environment-specific local overrides (gitignored)
APP_ENV is read from the OS environment first (Environ("APP_ENV")), then from
the merged base level (.env + .env.local). If APP_ENV is empty, only levels
1–2 load — fully compatible with single-file .env projects.
MyProject.accdb.src/
.env # APP_ENV=dev + shared keys
.env.local # gitignored — your machine overrides
.env.dev # dev connection strings
.env.dev.local # gitignored — dev machine overrides
.env.live # production connection strings
Base .env:
APP_ENV=dev
# shared non-secret config...
.env.dev:
conn_dev=ODBC;DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost;DATABASE=dev;Trusted_Connection=Yes;
- Edit
APP_ENVin.env(or set the OS environment variable). - Ensure the matching
.env.{APP_ENV}file exists with the correctconn_*keys. - Rebuild or merge from source so linked tables relink with the new connection strings.
Note: Layered .env resolution applies at build/import time. Runtime VBA
code that opens ADODB connections must read .env itself (or use a project-specific
loader). Linked tables bake in the resolved ODBC string when imported.
- Import/build resolution uses the merged config (all four levels).
-
Export writes go to the base
.envonly — auto-generatedconn_*entries are not written into.env.{APP_ENV}files.
An ODBC login prompt usually means:
- The
env:conn_*key referenced in source is missing from the resolved.envconfig for the activeAPP_ENV. - The SQL Server (or other ODBC target) is unreachable — ODBC falls back to a login dialog on timeout.
Check the build log for:
Connection key not found in .env file: conn_...
Compare db-connection.json priming keys and tbldefs/queries Connect values
against the keys present in your merged .env files.
| Option | Location | Purpose |
|---|---|---|
UseEnvForConnections |
vcs-options.json |
Auto / Always / Never for export sanitization |
EnvConnectionNames |
vcs-options.json |
Stable named keys (Tier 2 matching) |
| Problem | What to check |
|---|---|
| ODBC login on every build | Missing key in .env; compare log message Connection key not found with db-connection.json and tbldefs/queries Connect values |
| Wrong server after pull |
APP_ENV set? Layered file .env.{APP_ENV} overriding base .env
|
| Secrets committed to Git | Ensure .env, .env.local, .env.* are in .gitignore; use Use Git Integration to refresh template |
env: visible but build fails |
UseEnvForConnections in vcs-options.json; run export once to regenerate placeholders |
See also Options, Export-Import File Types, and FAQs.