Creating an Autonumber field

E

Ed Cohen

Question - I am trying to create a field that has the datatype of AutoNumber
in code. The help page that has the datatypes does not list anything that
corresponds to the AutoNumber datatype. I need this for a table I am creating
in VBA - Access 2000. The New values property is automatically set to
Increment. Again, how do you do this in VBA? Thanks.

Ed
 
D

Douglas J. Steele

Dim tdfCurr As DAO.TableDef
Dim fldID As DAO.Field

Set tdfCurr = CurrentDb().TableDefs("ExistingTable")
Set fldID = tdfCurr.CreateField("NewField", dbLong)
fldID.Attributes = dbAutoIncrField
tdfCurr.Fields.Append fldID
 
Top