HELP! How Do I CreateField Using Autonumber in VB

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
 
A

Allen Browne

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
 

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