Properties Collection
Access Developer Reference |
A Properties collection contains all the Property objects for a specific instance of an object.
Remarks
Every DAO object except the Connection and Error objects contains a Properties collection, which has certain built-in Property objects. These Property objects (which are often just called properties) uniquely characterize that instance of the object.
In addition to the built-in properties, you can also create and add your own user-defined properties. To add a user-defined property to an existing instance of an object, first define its characteristics with the CreateProperty method, then add it to the collection with the Append method. Referencing a user-defined Property object that has not yet been appended to a Properties collection will cause an error, as will appending a user-defined Property object to a Properties collection containing a Property object of the same name.
You can use the Delete method to remove user-defined properties from the Properties collection, but you can't remove built-in properties.
Note |
---|
A user-defined Property object is associated only with the specific instance of an object. The property isn't defined for all instances of objects of the selected type. |
To refer to a built-in Property object in a collection by its ordinal number or by its Name property setting, use any of the following syntax forms:
object.Properties(0)
object.Properties("name")
object.Properties![name]
For a built-in property, you can also use this syntax:
object.name
Note |
---|
For a user-defined property, you must use the full object.Properties("name") syntax. |
With the same syntax forms, you can also refer to the Value property of a Property object. The context of the reference will determine whether you are referring to the Property object itself or the Value property of the Property object.
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.
Visual Basic for Applications |
---|
|
This example tries to set the value of a user-defined property. If the property doesn't exist, it uses the CreateProperty method to create and set the value of the new property. The SetProperty procedure is required for this procedure to run.
Visual Basic for Applications |
---|
|
See Also