HELP! How Do I CreateField Using Autonumber in VB

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

I inherited a DAO database that is being widely used
throughout my company.

I need to be able to create several tables so that they
have Autonumber field. Is there a way in VB to create a
table?

I have tried:
Set tdfNew = db.CreateTableDef("NewTableDef")
tdfNew .Fields.Append .CreateField("AutoField", ????? )

However, I cannot find a TYPE code to replace the ?????
that meets my needs.

Thanks!
Rich
 
Use dbLong as the Type. AutoNumber is defined by the Attributes:

Dim fld As DAO.Field
Set fld = tdfNew.CreateField("ContractorID", dbLong)
fld.Attributes = dbAutoIncrField + dbFixedField
tblNew.Fields.Append fld
 
Back
Top