MajP
You've got your good things, and you've got mine.
- Local time
- Yesterday, 22:20
- Joined
- May 21, 2018
- Messages
- 8,992
I have an autonumber field called PersonID. In code I am trying to determine if a field is updateable. According to MS
I run this test
Which verifies the attributes as an autoincrement field, updateable, and fixed size. See attributes table. It returns a 49 which is 32, 16, 1.
Even though the attribute returns autoincr the DataUpdatable still shows as true which is not as MS help describes. Should be false. Any ideas?
The DataUpdatable property returns a value that indicates whether the data in the field represented by a Field object is updatable.
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 objectsI read that to say if the field is dbAutoIncrField then it returns false
I run this test
Code:
Public Sub Test()
Dim Rs As DAO.Recordset
Dim fld As DAO.Field
Set Rs = CurrentDb.OpenRecordset("Select PersonID from tblDemoUnbound")
Set fld = Rs.Fields("PersonID")
Debug.Print "Total Attributes: " & Rs.Fields("PersonID").Attributes
Debug.Print "Field is Autoincr: " & CStr((Rs.Fields("PersonID").Attributes And 16) = 16)
Debug.Print "Field is attribute Updateable: " & CStr((Rs.Fields("PersonID").Attributes And 32) = 32)
Debug.Print "Field is attribute Fixed: " & CStr((Rs.Fields("PersonID").Attributes And 1) = 1)
Debug.Print
Debug.Print "PersonID DataUpdatable: " & Rs.Fields("PersonID").DataUpdatable
End Sub
Which verifies the attributes as an autoincrement field, updateable, and fixed size. See attributes table. It returns a 49 which is 32, 16, 1.
Code:
Total Attributes: 49
Field is Autoincr: True
Field is attribute Updateable: True
Field is attribute Fixed: True
PersonID DataUpdatable: True
Constant | Value | Description |
---|---|---|
dbAutoIncrField | 16 | The field value for new records is automatically incremented to a unique Long integer that can't be changed (in a Microsoft Access workspace, supported only for Microsoft Access database engine database tables). |
dbDescending | 1 | The field is sorted in descending (Z to A or 100 to 0) order; this option applies only to a Field object in a Fields collection of an Index object. If you omit this constant, the field is sorted in ascending (A to Z or 0 to 100) order. This is the default value for Index and TableDef fields (Microsoft Access workspaces only). |
dbFixedField | 1 | The field size is fixed (default for Numeric fields). |
dbHyperlinkField | 32768 | The field contains hyperlink information (Memo fields only). |
dbSystemField | 8192 | The field stores replication information for replicas; you can't delete this type of field (Microsoft Access workspace only). |
dbUpdatableField | 32 | The field value can be changed. |
dbVariableField | 2 | The field size is variable (Text fields only).\ |
Even though the attribute returns autoincr the DataUpdatable still shows as true which is not as MS help describes. Should be false. Any ideas?