So I have the below VB that creates an access file in the default workspace, creates a table, create some fields in that table…just need to know the syntax for setting the first data type/field to autonumber…GUID, Counter, etc will not work as in Access SQL
' error handling usually goes here
dim ws as workspace
dim dbExample as database
dim tblMain as TableDef
dim fldMain as Field
dim idxMain as Index
set ws = workspace(0)
set dbExample = ws.CreateDatabase('string file path')
set tblMain = dbExample.CreateTableDef("tblMain")
set fldMain = tblMain.CreateField("ID", 'right here I do not know what to substitute for dbInteger to get the autonumber type to work )
tblMain.Fields.Append fldMain
etc to create other fields and indexes
so in this line:
set fldMain = tblMain.CreateField(“ID”, dbInteger)
i need to replace the dbInteger with something that VB reconizes as the autonumber property.
i have tried GUID, Counter, Autonumber, AutoIncrement….unfortunately none of these work
anyone know the syntax I am missing here?
Thanks,
Justin
See Creating an AutoNumber field from code at The access Web.
Here are the key lines from that linked page:
BTW, what you’re doing is not DDL.