Access/VBA Library


Changes a property of the current database. If not it does not exist, then it will be added.


ChangeProperty( propertyName, propertyType, propertyValue )
Name Type Description
propertyName String Required. Name of the property to be changed.
propertyType Variant Required. Type of the property to be changed. Should be one of the field type constants like dbInteger, dbText, dbDate....
propertyValue Variant Required. Value of the property. The type of the value should correspondend with the specified propertyType.
Return value

Boolean : True when the property has been changed or created, otherwise False.

Function ChangeProperty(propertyName As String, propertyType As Variant, propertyValue As Variant) As Boolean
    Const cErrPropertyNotFound = 3270

    Dim dbs As Database
    Dim prp As Property
    Set dbs = CurrentDb
    On Error GoTo ChangeProperty_Error
    dbs.Properties(propertyName) = propertyValue
    ' Property exist and is replaced
    ChangeProperty = True
    Exit Function
    If Err = cErrPropertyNotFound Then
        ' If the property does not exist then create it
        Set prp = dbs.CreateProperty(propertyName, propertyType, propertyValue)
        dbs.Properties.Append prp
        Resume Next
        ShowError propertyName & " : " & Err.Description, "ChangeProperty"
        ChangeProperty = False
        Resume ChangeProperty_Exit
    End If
End Function


  • When an error occured, an errormessage will pop up.