Class Property (DAO VBA)
A Property object represents a built-in or user-defined characteristic of a DAO object. To use a Property class variable it first needs to be instantiated, for example
Dim prp as Property
Set prp = Properties(Item:=1)
Inherited
Returns a value that indicates whether a Property object is inherited from an underlying object.
For built-in Property objects that represent predefined properties, the only possible return value is False. You can use the Inherited property to determine whether a user-defined Property was created for the object it applies to, or whether the Property was inherited from another object. For example, suppose you create a new Property for a QueryDef object and then open a Recordset object from the QueryDef object. This new Property will be part of the Recordset object's Properties collection, and its Inherited property will be set to True because the property was created for the QueryDef object, not the Recordset object.
Sub InheritedX()
Dim dbsNorthwind As Database
Dim tdfTest As TableDef
Dim rstTest As Recordset
Dim prpNew As Property
Dim prpLoop As Property
' Create a new property for a saved TableDef object, then
' open a recordset from that TableDef object.
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Set tdfTest = dbsNorthwind.TableDefs(0)
Set prpNew = tdfTest.CreateProperty("NewProperty", _
dbBoolean, True)
tdfTest.Properties.Append prpNew
Set rstTest = tdfTest.OpenRecordset(dbOpenForwardOnly)
' Show Name and Inherited property of the new Property
' object in the TableDef.
Debug.Print "NewProperty of " & tdfTest.Name & _
" TableDef:"
Debug.Print " Inherited = " & _
tdfTest.Properties("NewProperty").Inherited
' Show Name and Inherited property of the new Property
' object in the Recordset.
Debug.Print "NewProperty of " & rstTest.Name & _
" Recordset:"
Debug.Print " Inherited = " & _
rstTest.Properties("NewProperty").Inherited
' Delete new TableDef because this is a demonstration.
tdfTest.Properties.Delete prpNew.Name
dbsNorthwind.Close
End Sub
Name
Returns or sets the name of the specified object. Read/write String if the object has not been appended to a collection.
The Name property of a built-in property is always read-only. The maximum length for the name of a Property object is 64 characters.
Dim prp As DAO.Property: Set prp =
prp.Name =
Properties
Returns the Properties collection of the specified object.
Dim prp As DAO.Property: Set prp =
prp.Properties
Type
Sets or returns a value that indicates the operational type or data type of an object.
The setting or return value is a constant that indicates an operational or data type. For a Property object, this property is read/write until the object is appended to a collection or to another object, after which it's read-only. For a Property object, the possible settings and return values are described in the following table.
Dim prp As DAO.Property: Set prp =
prp.Type =
Value
Sets or returns the value of an variant. Read/write Variant.
The setting or return value is a Variant data type that evaluates to a value appropriate for the data type, as specified by the Type property of an object. Generally, the Value property is used to retrieve and alter data in Recordset objects. The Value property is the default property of the Field, Parameter, and Property objects. Therefore, you can set or return the value of one of these objects by referring to them directly instead of specifying the Value property. Trying to set or return the Value property in an inappropriate context (for example, the Value property of a Field object in the Fields collection of a TableDef object) will cause a trappable error.
Dim prp As DAO.Property: Set prp =
prp.Value =