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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top