Access/VBA Library

INI_KeyExists

Returns a Boolean indication if the item specified by index exists.

Syntax

INI_KeyExists( index )
Parameters
Name Type Description
index String Required. The index of the key in the INI-file (
.).
Return value

Boolean : True if the key exists within the given section, False otherwise.

Code
Public Function INI_KeyExists(ByVal index As String) As Boolean
    Dim default As String
    ' Create a time-dependend default value for the item
    default = Format$(Now(), "yyyymmddHhNnSs")
    
    ' If default is returned, the key does not exist
    If INI_GetValue(index, default) = default Then
        INI_KeyExists = False
    Else
        INI_KeyExists = True
    End If
End Function

See also

  • INI_GetValue
Example
' Check INI file for the key "version" in section "database"
If INI_KeyExist( "database.version" ) Then
   Debug.Print "Database initialized!"
Else
   ShowError "Database not connected!"
End If