G
Guest
Using Access 97. I am in database 1. I am trying to create a primary key in a
table in database 2 where the field already exists. The code I have come up
with is as follows:
Dim db As DAO.database
Dim td As DAO.TableDef
Dim id As DAO.Index
Dim fd As DAO.Field
Set db = OpenDatabase("c:\ABC.mdb")
Set td = db.TableDefs("Employees")
Set id = td.CreateIndex("PrimaryKey")
Set fd = id.CreateField("EmpID")
id.Primary = True
id.Required = True
id.Unique = True
td.Indexes.Append id
td.Indexes.Refresh
The error I get is "Error 3264: No field defined - Cannot append tabledef or
index."
Any help would be appreciated. Thanks in advance.
table in database 2 where the field already exists. The code I have come up
with is as follows:
Dim db As DAO.database
Dim td As DAO.TableDef
Dim id As DAO.Index
Dim fd As DAO.Field
Set db = OpenDatabase("c:\ABC.mdb")
Set td = db.TableDefs("Employees")
Set id = td.CreateIndex("PrimaryKey")
Set fd = id.CreateField("EmpID")
id.Primary = True
id.Required = True
id.Unique = True
td.Indexes.Append id
td.Indexes.Refresh
The error I get is "Error 3264: No field defined - Cannot append tabledef or
index."
Any help would be appreciated. Thanks in advance.