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

  • Thread starter Thread starter Bo Hansson
  • Start date Start date
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
 
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
 
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
 
Back
Top