Access/VBA Library

INI-Files

This module contains function to read from and write to an INI-file. Each project can have just one INI-file and it is located in a subfolder of the default Windows AppData folder (for example C:\Users\USERNAME\AppData\Roaming). The name of the subfolder is the application title (see GetAppicationTitle). Suppose you have a project named VBADocSys, than the INI file can be C:\Users\USERNAME\AppData\Roaming\VBADocSys\VBADocSys.ini.

Module: mdlINIfile

Remarks

  • It is recommened by Microsoft to store user-settings in the Windows-registry. But, some companies follow a very strict authorization policy and do not allow all users to change the registry. In these cases I use an INI-file to store user-settings.

See also

  • GetApplicationFolder
Example
' Save the last access date in section "access"
INI_SetValue( "access.last", Format( now(), "yyyy-mm-dd" )
' Perform installation actions
If INI_GetValue( "config.version" ) = "2.1" Then
   ..... ' Some version specific code here
   INI_SetValue( "config.version", "2.2" )
End If
'
' Content if INI-file:
'[access]
'last=2016-07-12
'[config]
'version=2.2
'autosave=1
'...

Topics