Hello,
I am using Accss 2000 and i am using VBA to create a table.
I have created the table fine but I would like to know how I assign one of the fields as a primary key and also create indexes.
Here is the code I have created for the CreateTable:
[red]
Sub CreatePFEPTable()
Dim tdfNew As TableDef
Dim db As Database
Set db = CurrentDb
Set tdfNew = db.CreateTableDef("PFEP"
With tdfNew
.Fields.Append .CreateField("Item", dbLong)[/red] [green] ' This is the field I want as Primary Key [/green] [red]
.Fields.Append .CreateField("Carry-Over", dbText, 20)
.Fields.Append .CreateField("GSDB Code", dbText, 15)
.Fields.Append .CreateField("IPF Code", dbText, 15)
.Fields.Append .CreateField("Supplier", dbText, 120)
.Fields.Append .CreateField("Country", dbText, 50)
.Fields.Append .CreateField("City", dbText, 100)
.Fields.Append .CreateField("IPF Part No", dbText, 50)
.Fields.Append .CreateField("Part Name", dbText, 50)
.Fields.Append .CreateField("Deliver to", dbText, 50)
.Fields.Append .CreateField("Pieces Per Car", dbDouble)
.Fields.Append .CreateField("Avg Pieces Per Car", dbDouble)
.Fields.Append .CreateField("Pallet Length", dbDouble)
.Fields.Append .CreateField("Pallet Width", dbDouble)
.Fields.Append .CreateField("Pallet Hight", dbDouble)
.Fields.Append .CreateField("Folded Height", dbDouble)
.Fields.Append .CreateField("Container Code", dbText, 25)
.Fields.Append .CreateField("Packaging Status", dbText, 20)
.Fields.Append .CreateField("Return Type", dbText, 60)
End With
db.TableDefs.Append tdfNew
End Sub
[/red]
Your help will be greatly appreciated,
Cheers,
Hayden
I am using Accss 2000 and i am using VBA to create a table.
I have created the table fine but I would like to know how I assign one of the fields as a primary key and also create indexes.
Here is the code I have created for the CreateTable:
[red]
Sub CreatePFEPTable()
Dim tdfNew As TableDef
Dim db As Database
Set db = CurrentDb
Set tdfNew = db.CreateTableDef("PFEP"
With tdfNew
.Fields.Append .CreateField("Item", dbLong)[/red] [green] ' This is the field I want as Primary Key [/green] [red]
.Fields.Append .CreateField("Carry-Over", dbText, 20)
.Fields.Append .CreateField("GSDB Code", dbText, 15)
.Fields.Append .CreateField("IPF Code", dbText, 15)
.Fields.Append .CreateField("Supplier", dbText, 120)
.Fields.Append .CreateField("Country", dbText, 50)
.Fields.Append .CreateField("City", dbText, 100)
.Fields.Append .CreateField("IPF Part No", dbText, 50)
.Fields.Append .CreateField("Part Name", dbText, 50)
.Fields.Append .CreateField("Deliver to", dbText, 50)
.Fields.Append .CreateField("Pieces Per Car", dbDouble)
.Fields.Append .CreateField("Avg Pieces Per Car", dbDouble)
.Fields.Append .CreateField("Pallet Length", dbDouble)
.Fields.Append .CreateField("Pallet Width", dbDouble)
.Fields.Append .CreateField("Pallet Hight", dbDouble)
.Fields.Append .CreateField("Folded Height", dbDouble)
.Fields.Append .CreateField("Container Code", dbText, 25)
.Fields.Append .CreateField("Packaging Status", dbText, 20)
.Fields.Append .CreateField("Return Type", dbText, 60)
End With
db.TableDefs.Append tdfNew
End Sub
[/red]
Your help will be greatly appreciated,
Cheers,
Hayden