garrenb
asked on
Creating an Auto Number field in MSAccess using "DbAutoIncrField "
Hi Guys,
If I wanted to create an Autonumber field called "Id" in an MS Access table , what extra would I need to add to the code below...
Dim dbsNorthwind As Database
Dim tdfNew As TableDef
Dim fldLoop As Field
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("Northwind.md b")
Set tdfNew = dbsNorthwind.CreateTableDe f("NewTabl eDef")
' Create and append new Field objects for the new
' TableDef object.
With tdfNew
' The CreateField method will set a default Size
' for a new Field object if one is not specified.
.Fields.Append .CreateField("TextField", dbText)
.Fields.Append .CreateField("IntegerField ", dbInteger)
.Fields.Append .CreateField("DateField", dbDate)
End With
dbsNorthwind.TableDefs.App end tdfNew
Thanx in advance,
GarrenB
If I wanted to create an Autonumber field called "Id" in an MS Access table , what extra would I need to add to the code below...
Dim dbsNorthwind As Database
Dim tdfNew As TableDef
Dim fldLoop As Field
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("Northwind.md
Set tdfNew = dbsNorthwind.CreateTableDe
' Create and append new Field objects for the new
' TableDef object.
With tdfNew
' The CreateField method will set a default Size
' for a new Field object if one is not specified.
.Fields.Append .CreateField("TextField", dbText)
.Fields.Append .CreateField("IntegerField
.Fields.Append .CreateField("DateField", dbDate)
End With
dbsNorthwind.TableDefs.App
Thanx in advance,
GarrenB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey Cassasus,
Following on from here, is it easy to set a field's attribute to Allow Zero Length?
50 Points on offer for u.
Thanks,
GarrenB
Following on from here, is it easy to set a field's attribute to Allow Zero Length?
50 Points on offer for u.
Thanks,
GarrenB
ASKER
You know I must have tried almost every method of getting this to work. If I had asked this question 2 hours ago I might have some hair left.
Many thanks,
Garren