Creating an Autonumber field

  • Thread starter Thread starter Ed Cohen
  • Start date Start date
E

Ed Cohen

Question - I am trying to create a field that has the datatype of AutoNumber
in code. The help page that has the datatypes does not list anything that
corresponds to the AutoNumber datatype. I need this for a table I am creating
in VBA - Access 2000. The New values property is automatically set to
Increment. Again, how do you do this in VBA? Thanks.

Ed
 
Dim tdfCurr As DAO.TableDef
Dim fldID As DAO.Field

Set tdfCurr = CurrentDb().TableDefs("ExistingTable")
Set fldID = tdfCurr.CreateField("NewField", dbLong)
fldID.Attributes = dbAutoIncrField
tdfCurr.Fields.Append fldID
 

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

Back
Top