|
|

Checking if a Field in a Table is an AutoNumber
Because an AutoNumber field is only really a self-incrementing Long Integer field, you cannot just check the Field's Type to see if it is an AutoNumber. Instead, you must check the Attributes property of the field:
Function fIsFieldAutoNumber(strTableName As String, strFieldName As String) As Boolean
On Error GoTo E_Handle
Dim db As Database
Dim tdf As TableDef
Dim fld As Field
Set db = DBEngine(0)(0)
Set tdf = db.TableDefs(strTableName)
Set fld = tdf.Fields(strFieldName)
If (fld.Attributes And dbAutoIncrField) Then fIsFieldAutoNumber = True
fExit:
On Error Resume Next
Exit Function
E_Handle:
MsgBox Err.Description & vbCrLf & "fIsFieldAutoNumber", vbOKOnly + vbCritical, "Error: " & Err.Number
Resume fExit
End Function
|
Top
HOME |
NEW |
TABLES |
QUERIES |
FORMS |
REPORTS |
GENERAL |
API |
DOWNLOADS |
TUTORIAL |
RESOURCES
E-MAIL
Copyright & Disclaimer
|
| |