Property Object, Properties Collection Example

This example creates a user-defined property for the current database, sets its Type and Value properties, and appends it to the Properties collection of the database. Then the example enumerates all properties in the database. See the properties listed in the Property summary topic for additional examples.

Sub PropertyX()

    Dim dbsNorthwind As Database
    Dim prpNew As Property
    Dim prpLoop As Property

    Set dbsNorthwind = OpenDatabase("Northwind.mdb")

    With dbsNorthwind
        ' Create and append user-defined property.
        Set prpNew = .CreateProperty()
        prpNew.Name = "UserDefined"
        prpNew.Type = dbText
        prpNew.Value = "This is a user-defined property."
        .Properties.Append prpNew

        ' Enumerate all properties of current database.
        Debug.Print "Properties of " & .Name
        For Each prpLoop In .Properties
            With prpLoop
                Debug.Print "  " & .Name
                Debug.Print "    Type: " & .Type
                Debug.Print "    Value: " & .Value
                Debug.Print "    Inherited: " & _
                    .Inherited
            End With
        Next prpLoop

        ' Delete new property because this is a 
        ' demonstration.
        .Properties.Delete "UserDefined"
    End With

End Sub