INI File Toolbox for MS Access – 13 Functions for Configuration Management

Where is the best place to store settings, configurations and paths? Often in the database – but you can’t do entirely without external files. This VBA toolbox covers everything around INI files with 13 functions: update-proof, robust, portable and without any dependencies.

As Access developers, we constantly face the same question: where is the best place to store user settings, configurations and paths? The obvious answer is the database itself – and that works great in many scenarios. But in practice you still can’t do without external files.

Why add an INI file?

I split my applications into frontend and backend. The frontend contains a settings table with the path to the backend. The crux: as soon as I roll out a frontend update, the internal settings table is empty again – the path would be gone. So I also save the backend path externally in a small INI file. For users this means: no more dialogs, no confusion, just business as usual.

INI is a simple, robust format that has reliably done its job for decades. Sometimes the best decision is not “either/or”, but a clever combination of both worlds.

The game changer: updates without data loss

My proven start workflow:

  1. Frontend starts
  2. Check the backend path in the frontend table
  3. Path invalid? → read the INI file
  4. INI found? → connect the backend automatically
  5. No INI? → show a file dialog (only on first start), save the path in the FE and the INI
  6. Delete existing linked tables
  7. Relink all backend tables (always up to date with the latest backend)

After an update, the application starts immediately with the saved settings – no annoying dialogs, no support effort.

The 13 functions of the toolbox

1. INI_ReadValue – read values. The basic function for reading configuration values.

strBackendPath = INI_ReadValue(strIniPath, "Database", "BackendPath", "")

2. INI_WriteValue – write/update values. Automatically creates the file and section if they don’t exist.

INI_WriteValue strIniPath, "Database", "BackendPath", strSelectedPath

3. INI_PrintAll – print the complete file. Displays the entire content formatted in the Immediate Window – perfect for debugging.

INI_PrintAll CurrentProject.Path & "\config.ini"

4. INI_GetSections – list all sections. Returns a collection of all sections.

Set colSections = INI_GetSections(strIniPath)
For Each varSection In colSections
    Debug.Print "Found section: " & varSection
Next

5. INI_GetKeys – all keys of a section. Perfect for dynamic processing of all settings.

Set colKeys = INI_GetKeys(strIniPath, "Database")
For Each varKey In colKeys
    Debug.Print varKey & " = " & INI_ReadValue(strIniPath, "Database", CStr(varKey))
Next

6. INI_DeleteSection – delete a whole section.

If INI_SectionExists(strIniPath, "OldModule") Then
    INI_DeleteSection strIniPath, "OldModule"
End If

7. INI_DeleteKey – delete a single key.

INI_DeleteKey strIniPath, "Session", "TempPassword"

8. INI_SectionExists – check a section.

If Not INI_SectionExists(strIniPath, "DatabaseV2") Then
    ' create the section ...
End If

9. INI_KeyExists – check a key.

If Not INI_KeyExists(strIniPath, "Features", "AutoBackup") Then
    INI_WriteValue strIniPath, "Features", "AutoBackup", "True"
End If

10. INI_PrintStructured – structured output. Displays the INI hierarchically – ideal for documentation.

INI_PrintStructured strIniPath

11. INI_GetAllValues – dictionary of all values. Retrieves all key-value pairs of a section as a dictionary.

Set dictDB = INI_GetAllValues(strIniPath, "Database")
Debug.Print "Server: " & dictDB("Server")
Debug.Print "Port: " & dictDB("Port")
Debug.Print "Timeout: " & dictDB("Timeout")

12. INI_ValidateFormat – validate the format. Checks the file for missing brackets, duplicate keys and invalid syntax.

If Not INI_ValidateFormat(strImportedIniPath) Then
    MsgBox "The imported configuration is invalid!", vbCritical
End If

Checks include: file exists and is readable · sections formatted correctly [SectionName] · no duplicate sections · no duplicate keys within a section · key-value pairs contain = · no excessively long lines (> 1000 characters).

13. INI_Compare – compare two INI files. The best for versioning and migration management.

If Not INI_Compare(strOldConfig, strNewConfig) Then
    Debug.Print "Changes detected - details in the Immediate Window"
    ' shows: new/removed sections, changed values, new/deleted keys
End If

Perfect for version comparison after updates, troubleshooting, documenting changes and warnings on critical deviations.

Real-world use cases

Multi-backend support:

INI_WriteValue strIniPath, "Backends", "Production", "\\Server\DB\Prod.accdb"
INI_WriteValue strIniPath, "Backends", "Test", "\\Server\DB\Test.accdb"
INI_WriteValue strIniPath, "Backends", "Development", "C:\Dev\DB.accdb"
INI_WriteValue strIniPath, "Settings", "CurrentEnvironment", "Production"

User-specific settings:

INI_WriteValue strIniPath, "UI", "Language", "DE"
INI_WriteValue strIniPath, "UI", "Theme", "Dark"
INI_WriteValue strIniPath, "UI", "FontSize", "12"
INI_WriteValue strIniPath, "Export", "DefaultFolder", "C:\Users\Marcus\Exports"

The advantages at a glance

  • Update-proof: the INI survives frontend updates.
  • User-friendly: no repeated entries after updates.
  • Robust: Windows API, proven for decades.
  • Portable: simple text files, usable anywhere.
  • Debuggable: open and check directly in the editor.
  • 32/64-bit and no dependencies – only the Windows API, no references needed.

What’s next: in an upcoming article I’ll show a tool for automatic backend connections at startup – with multiple backends, fallback strategies and error handling. INI files are the perfect foundation for this.

Just give it a try

Using the included testing form, you can try out the functions directly and learn them step by step. You’ll find the detailed description directly in the code, well documented as usual.

Download

A VBA toolbox for MS Access with 13 functions for INI files: read, write, manage sections/keys, validate and compare – update-proof, robust and without dependencies.

âś• Newsletter

Newsletter