INI File Toolbox โ complete solution for configuration management!
Why INI files? The underestimated power for Access developers! ๐ช
As Access developers, we are constantly faced with the same question: Where is the best place to store user settings, configurations, and paths?
The obvious answer is: in the database itself.
And yes โ this works great in many scenarios. But in practice, it quickly becomes apparent that I still can't do without external files.
I divide my applications into frontend and backend in the traditional way. The frontend contains a settings table where I save the path to the backend. When the application is first started, this path is still empty, so the user is presented with a file dialog and selects the backend. The path is then saved โ conveniently and reliably, without having to reconnect each time.
So far, so good. So why add an INI file?
The crux of the matter: as soon as I roll out an update to the frontend, the internal settings table is back to square one โ the path would be gone. So I also save the backend path externally in a small INI file. For users, this means no more dialog boxes, no confusion, just business as usual.
And why an INI-file?
Because it is a simple, robust format that has been doing what it is supposed to do reliably for decades. For configurations that need to remain stable, it is often the most pragmatic solution.
My conclusion:
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 in practice
1. Frontend starts
2. Check backend path in frontend table
3. Path invalid? โ Read INI file
4. INI found? โ Connect backend automatically
5. No INI? โ Show file dialog (only on first start), save path in FE and INI file
6. Delete existing linked tables
7. Relink all backend tables (so they are always up to date with the latest backend version)
After an update, the application starts immediately with the saved settings โ no annoying dialogs, no support effort!
I will publish an article about my frontend start function (FE/BE link, license check, hiding the menu bar, etc.) at a later date.
๐งฐ The complete INI File Toolbox โ 13 powerful functions!
I have developed a comprehensive VBA library that covers EVERYTHING related to INI files. Not just my use case for the backend connection:
๐ 1. INI_ReadValue - Read values
The basic function for reading configuration values.
strBackendPath = INI_ReadValue(strIniPath, "Database", "BackendPath", "")
โ๏ธ 2. INI_WriteValue - write or update values
Saves values to the INI file. Automatically creates file and section if they don't exist!
INI_WriteValue strIniPath, "Database", "BackendPath", strSelectedPath
๐จ๏ธ 3. INI_PrintAll - Print complete file
Displays the entire content formatted in the Immediate Window โ perfect for debguggin!
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 "Gefundene Sektion: " & varSection
Next
๐ 5. INI_GetKeys - List 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 whole section
Removes an entire configuration section.
If INI_SectionExists(strIniPath, "OldModule") Then
INI_DeleteSection strIniPath, "OldModule"
End If
โ 7. INI_DeleteKey -Delete a key
Deletes specific settings.
INI_DeleteKey strIniPath, "Session", "TempPassword"
โ๏ธ 8. INI_SectionExists - Checks a section
Checks if a section exists.
If Not INI_SectionExists(strIniPath, "DatabaseV2") Then โฆ
โ 9. INI_KeyExists - Checks a key
Checks whether a configuration area exists.
If Not INI_KeyExists(strIniPath, "Features", "AutoBackup") Then
INI_WriteValue strIniPath, "Features", "AutoBackup", "True"
End If
๐๏ธ 10. INI_PrintStructured - Print structured
Displays the INI file in a hierarchical structure โ ideal for documentation!
INI_PrintStructured strIniPath
๐ฆ 11. INI_GetAllValues - Dictionary all values
Retrieves all key-value pairs of a section as a dictionary โ super efficient!
Set dictDB = INI_GetAllValues(strIniPath, "Database")
Debug.Print "Server: " & dictDB("Server")
Debug.Print "Port: " & dictDB("Port")
Debug.Print "Timeout: " & dictDB("Timeout")
๐ 12. INI_ValidateFormat - Format validation
Checks the INI file for errors: missing brackets, duplicate keys, invalid syntax.
If Not INI_ValidateFormat(strImportedIniPath) Then
MsgBox "Die importierte Konfiguration ist fehlerhaft!", vbCritical
End If
Validation Checks:
- โ File exists and is readable
- โ Sections are 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 "รnderungen erkannt - siehe Details im Immediate Window"
' Shows detailed:
' - New sections
' - Removed sections
' - Changed values
' - New/deleted keys
End If
Perfect for:
- ๐ Version comparison after updates
- ๐ Troubleshooting configuration problems
- ๐ Documentation of changes
- โ ๏ธ Warning in case of critical deviations
๐ Real-World Use Cases
Use Case 1: 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"
Use Case 2: 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: INI remains intact during front-end 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: Works in all Access versions
โ
No dependencies: Only Windows API, no references necessary
๐ฎ Whatโs next?
In an upcoming article, I'll show you a tool for automatic backend connections at startup โ with support for multiple backends simultaneously, fallback strategies, and error handling. INI files are the perfect foundation for this!
๐งช Try it out
Using my little testing form you can try the functions directly. This makes it easy to learn the functions step by step. Do you develop a lot with Access? Then give it a try โ Iโm looking forward to your feedback or ideas for additional functions! ๐
You will find the detailed description and all instructions directly in the code - well documented as usual.
DOWNLOAD
Version: 1.0 26th November 2025
