>

Inherited Property

Applies To

Property Object.

Description

Returns a value that indicates whether a Property object is inherited from an underlying object. This property setting is read-only. True (-1) indicates that the Property object is inherited. For built-in Property objects that represent predefined properties, False (0) is the only possible return value.

Remarks

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 created for another object. For example, suppose you create a property for a QueryDef object and then open a Recordset object from the QueryDef object. This 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.

See Also

CreateProperty Method, QueryDef Object.

Specifics (Microsoft Access)

Microsoft Access defines a number of properties which apply to data access objects. Because these properties are defined by Microsoft Access, the Microsoft Jet database engine doesn't recognize them automatically. To set one of these properties in Visual Basic, you must first create the property using the CreateProperty method and then append it to the Properties collection of the object. For more information, search the online index for the Property object topic.

When you create an object based on another object, the derived object inherits the properties of the original object. You can use the Inherited property to determine whether one of these properties was created for the object it is applied to, or if the property was inherited from another object.

For example, suppose you want to set the Microsoft Access DatasheetFontName property for a TableDef object. If you are setting this property for the first time, you will need to create a corresponding Property object and append it to the Properties collection of the TableDef object. The Inherited property of the new Property object returns False.

If you then create a new QueryDef object based on the table corresponding to the TableDef object, the DatasheetFontName property will be included in the Properties collection of the QueryDef object. The Inherited property of a Property object corresponding to this property returns True.

Example

This example creates a Recordset object from a QueryDef object, creates a new property, and indicates whether the property is inherited. Then the example prints the name of each field in the Recordset and, for each property of each field, it prints the Name, Type, Value, and Inherited property value settings.


Dim dbsDefault As Database, qdfTest As QueryDef
Dim rstTest As Recordset, prpMoose As Property
Dim intField As Integer, intProp As Integer
Set dbsDefault =  DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb")
Set qdfTest = dbsDefault.QueryDefs(0)
Set prpMoose = qdfTest.CreateProperty("Moose",dbBoolean, True)
qdfTest.Properties.Append prpMoose
Set rstTest = qdfTest.OpenRecordset()
Debug.Print "Is qdfTest.Properties(""Moose"")inherited? "
Debug.Print qdfTest.Properties("Moose").Inherited
Debug.Print "Is rstTest.Properties(""Moose"")inherited? "
Debug.Print rstTest.Properties("Moose").Inherited
For intField = 0 To rstTest.Fields.Count - 1
    Debug.Print rstTest.Fields(intField).Name
    On Error Resume Next
    For intProp = 0 To rstTest.Fields(intField).Properties.Count - 1
        Debug.Print rstTest.Fields(intField).Properties(intProp).Name
        Debug.Print rstTest.Fields(intField).Properties(intProp).Type
        Debug.Print rstTest.Fields(intField).Properties(intProp).Value
        Debug.Print _
rstTest.Fields(intField).Properties(intProp).Inherited Next intProp Next intField dbsDefault.Close
Example (Microsoft Access)

The following example creates a Property object in the Properties collection of a TableDef object, and then creates a new QueryDef object based on the same table. The Property object automatically exists in the Properties collection of the new QueryDef object. Next, the procedure checks the Inherited property for the Property objects in the Properties collections of both the TableDef and the QueryDef objects.

In the following example, the Microsoft Access DatasheetFontItalic property is created and appended to the Properties collection of the TableDef object. The DatasheetFontItalic property is defined by Microsoft Access rather than by the Microsoft Jet database engine. However, the property applies to data access objects. Therefore, in order to set it from Visual Basic code, you must first create a Property object corresponding to that property and append it to the Properties collection of the data access object. It is necessary to create the property only the first time you set it.


Sub CheckInherited()
    Dim dbs As Database, tdfOrders As TableDef, qdfOrders As QueryDef
    Dim prpTableDef As Property, prpQueryDef As Property
    Dim strSQL As String

    ' Return Database variable that points to current database.
    Set dbs = CurrentDb
    Set tdfOrders = dbs.TableDefs!Orders
    ' Create Property object and append to Properties collection.
    Set prpTableDef = tdfOrders.CreateProperty("DatasheetFontItalic", _
        dbBoolean, True)
    tdfOrders.Properties.Append prpTableDef
    Debug.Print prpTableDef.Inherited
    ' Create QueryDef based on Orders table.
    strSQL = "SELECT * FROM Orders WHERE ShipCountry = 'USA'"
    Set qdfOrders = dbs.CreateQueryDef("USAOrders", strSQL)
    ' Return Property object pointing to property.
     Set prpQueryDef = qdfOrders.Properties!DatasheetFontItalic
     Debug.Print prpQueryDef.Inherited
End Sub