L
LF
The vb code snipet below opens a recordset of a given table variable and
loops through the recordset fields testing each field type until an
autonumber is found. Is there a shorter method to find the name of any
tables' unique id field?
Also I want to change the datatype of this field from AutoNumber to Number;
I would greatly appreciate any advice on how to do so.
Set db = CurrentDb()
strSQL = "SELECT * FROM [" & strTbl & "];"
Set rs = db.OpenRecordset(strSQL)
For Each fld In rs.Fields
If fld.Type = AutoNumber Then
Debug.Print fld.Name & " = " & fld.Value
strID = fld.Name
Else
Debug.Print fld.Type & " is not an autonumber"
End If
Next fld
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
loops through the recordset fields testing each field type until an
autonumber is found. Is there a shorter method to find the name of any
tables' unique id field?
Also I want to change the datatype of this field from AutoNumber to Number;
I would greatly appreciate any advice on how to do so.
Set db = CurrentDb()
strSQL = "SELECT * FROM [" & strTbl & "];"
Set rs = db.OpenRecordset(strSQL)
For Each fld In rs.Fields
If fld.Type = AutoNumber Then
Debug.Print fld.Name & " = " & fld.Value
strID = fld.Name
Else
Debug.Print fld.Type & " is not an autonumber"
End If
Next fld
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing