VBA for Access 2003 - DDL help with creating access file: setting the Autonumber data type
Posted
by Justin
on Stack Overflow
See other posts from Stack Overflow
or by Justin
Published on 2010-05-17T22:00:08Z
Indexed on
2010/05/17
22:10 UTC
Read the original article
Hit count: 538
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
© Stack Overflow or respective owner