Applies To Field object.
Description
Returns a value that indicates whether the data in the field represented by a Field object is updatable.
Return Values The return value is a Boolean data type that returns True if the data in the field is updatable. Remarks Use this property to determine whether you can change the Value property setting of a Field object. This property is always False on a Field object whose Attributes property is dbAutoIncrField. You can use the DataUpdatable property on Field objects that are appended to the Fields collection of QueryDef, Recordset, and Relation objects, but not the Fields collection of Index or TableDef objects.See Also Attributes property, Updatable property, Value property.
Example This example demonstrates the DataUpdatable property using the first field from six different Recordsets. The DataOutput function is required for this procedure to run.Sub DataUpdatableX()
Dim dbsNorthwind As Database
Dim rstNorthwind As Recordset
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
With dbsNorthwind
' Open and print report about a table-type Recordset.
Set rstNorthwind = .OpenRecordset("Employees")
DataOutput rstNorthwind
' Open and print report about a dynaset-type Recordset.
Set rstNorthwind = .OpenRecordset("Employees", _
dbOpenDynaset)
DataOutput rstNorthwind
' Open and print report about a snapshot-type Recordset.
Set rstNorthwind = .OpenRecordset("Employees", _
dbOpenSnapshot)
DataOutput rstNorthwind
' Open and print report about a forward-only-type Recordset.
Set rstNorthwind = .OpenRecordset("Employees", _
dbOpenForwardOnly)
DataOutput rstNorthwind
' Open and print report about a Recordset based on
' a select query.
Set rstNorthwind = _
.OpenRecordset("Current Product List")
DataOutput rstNorthwind
' Open and print report about a Recordset based on a
' select query that calculates totals.
Set rstNorthwind = .OpenRecordset("Order Subtotals")
DataOutput rstNorthwind
.Close
End With
End Sub
Function DataOutput(rstTemp As Recordset)
With rstTemp
Debug.Print "Recordset: " & .Name & ", ";
Select Case .Type
Case dbOpenTable
Debug.Print "dbOpenTable"
Case dbOpenDynaset
Debug.Print "dbOpenDynaset"
Case dbOpenSnapshot
Debug.Print "dbOpenSnapshot"
Case dbOpenForwardOnly
Debug.Print "dbOpenForwardOnly"
End Select
Debug.Print " Field: " & .Fields(0).Name & ", " & _
"DataUpdatable = " & .Fields(0).DataUpdatable
Debug.Print
.Close
End With
End Function
Example (Microsoft Access)
The following example creates two Recordset objects, a dynaset-type Recordset object and a snapshot-type Recordset object, from the same table. The procedure then checks the DataUpdatable property for the LastName field in each Recordset object. The setting of the DataUpdatable property is True (–1) for the dynaset-type Recordset object, and False (0) for the snapshot-type Recordset object.
Sub CheckUpdatable()
Dim dbs As Database
Dim rstDynaset As Recordset, rstSnapshot As Recordset
Dim fldDynaset As Field, fldSnapshot As Field
' Return reference to current database.
Set dbs = CurrentDb
' Open dynaset-type Recordset object.
Set rstDynaset = dbs.OpenRecordset("Employees", dbOpenDynaset)
' Open snapshot-type Recordset object.
Set rstSnapshot = dbs.OpenRecordset("Employees", dbOpenSnapshot)
' Get Field object variables pointing to
' field in each Recordset object.
Set fldDynaset = rstDynaset.Fields!LastName
Set fldSnapshot = rstSnapshot.Fields!LastName
' Get current record.
rstDynaset.MoveFirst
rstSnapshot.MoveFirst
' Display value of DataUpdatable property for each
' Recordset object.
Debug.Print "DataUpdatable (Dynaset-type Recordset): "; _
fldDynaset.DataUpdatable
Debug.Print "DataUpdatable (Snapshot-type Recordset): "; _
fldSnapshot.DataUpdatable
rstDynaset.Close
rstSnapshot.Close
Set dbs = Nothing
End Sub