vipersmind
it can't be!
- Local time
- Tomorrow, 07:45
- Joined
- Dec 26, 2002
- Messages
- 82
I wish to make a new table with ID as a autonumber field.
I am using the code below to achieve most of this.
I can't find the right data type to get the ID as autonumber
Can you?
I am using the code below to achieve most of this.
I can't find the right data type to get the ID as autonumber
Can you?
Code:
Function makestag1()
Dim db As Database
Dim tbl As TableDef
Dim fld As Field
Dim idx As Index
'create references to the database
Set db = CurrentDb()
' specify what to call the new table
Set tbl = db.CreateTableDef("tbl_Validation_Development_FromToStag1")
' create the field references for the new table
Set fld = tbl.CreateField("ID", [COLOR=red]dbGUID[/COLOR] )
tbl.Fields.Append fld
Set fld = tbl.CreateField("HoleID", dbText, 20)
tbl.Fields.Append fld
Set fld = tbl.CreateField("SampleID", dbText, 10)
tbl.Fields.Append fld
Set fld = tbl.CreateField("From", dbDouble)
tbl.Fields.Append fld
Set fld = tbl.CreateField("To", dbDouble)
tbl.Fields.Append fld
' append the new fields to the table
db.TableDefs.Append tbl
' create a primary key index
Set idx = tbl.CreateIndex("PrimaryKey")
Set fld = idx.CreateField("ID")
idx.Primary = True
idx.Unique = True
idx.Fields.Append fld
tbl.Indexes.Append idx
End Function