Inherited Property Example

This example use the Inherited property to determine if a user-defined Property object was created for a Recordset object or for some underlying 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