CreateField("ID", dbAutoIncrField) results in another data type

B

Bo Hansson

When creating Access tables from my Word VBA application I try the
following:

tdf.Fields.Append .CreateField("ID", dbAutoIncrField)

to get an auto incrementing field. The table is nicely created, but the data
type of
the auto field becomes an Integer. What's wrong ?

/BosseH
 
D

Douglas J. Steele

You need to add a Long Integer, then change its attribute to
dbAutoIncrField:

Dim fld1 As DAO.Field

Set fld1 = tdf.CreateField("ID", dbLong)
fld1.Attributes = fld1.Attributes + dbAutoIncrField
tdf.Fields.Append fld1
 
B

Bo Hansson

Doug, thanks a lot !

/BosseH
Douglas J. Steele said:
You need to add a Long Integer, then change its attribute to
dbAutoIncrField:

Dim fld1 As DAO.Field

Set fld1 = tdf.CreateField("ID", dbLong)
fld1.Attributes = fld1.Attributes + dbAutoIncrField
tdf.Fields.Append fld1
 
Top