PDA

Click to See Complete Forum and Search --> : AUTONUMBER


PITBULLCJR
May 27th, 2000, 01:17 AM
OK got a question you can create fields like so:
Set tdftable = dbsData.CreateTableDef("Vocab")
With tdftable
.Fields.Append .CreateField("Word", dbText)
.Fields.Append .CreateField("Def", dbText)
End With
dbsData.TableDefs.Append tdftable

Now in the database there is a way to create it with that autonumber function. How can you do that in code.
I thought it would be something like this
Set tdftable = dbsData.CreateTableDef("Vocab")
With tdftable
.Fields.Append .CreateField("ID", dbautonumber)
.Fields.Append .CreateField("Word", dbText)
.Fields.Append .CreateField("Def", dbText)
End With
dbsData.TableDefs.Append tdftable
but thats no good. thanks

BruceG
May 27th, 2000, 03:34 AM
I don't know if there is way to do this with the CreateField method, but there is a way to do it with an embedded SQL statement (using the Database object's Execute method). You could do this:

dbsData.Execute _
"CREATE TABLE Vocab (ID AUTOINCREMENT, Word TEXT, Def TEXT)"

PITBULLCJR
May 27th, 2000, 03:48 AM
Thanks!! It Works Great!!!