Databases Reference
In-Depth Information
& " properties: " & vbCrLf & str
End Sub
Running this procedure gives the window shown in Figure 14-10, where each line has the
form
Name
=
Value
(Type)
Inherited
.
Figure 14-10. Window generated from executing exaProperties
14.6.3 User-Defined Properties
We mentioned that a user can add user-defined properties to an object. Let us consider an
example of adding a new property to the BOOKS
TableDef
object.
The code in Example 14-8 adds the user-defined property named
UserProperty
to the
BOOKS table. It uses the
CreateProperty
method of the
TableDef
object.
Example 14-8. A user-defined properties example
Sub
exaUserDefinedProperty( )
' Add user-defined property to BOOKS TableDef object
Dim db As DATABASE
Dim tbl As TableDef
Dim prp As Property
Dim str As String
Set db = CurrentDb
Set tbl = db!BOOKS
' Create new property using
CreateProperty
method
Set prp = tbl.CreateProperty("UserProperty", dbText,"Programming DAO is
fun.")
' Append it to Properties collection
tbl.Properties.Append prp