Article ID: 195837
Article Last Modified on 1/8/2003
Dim Fld as Field
Dim Tbl as Recordset
Dim Rel as Relation
Dim db as Database
Set db = OpenDatabase("nwind.mdb", True)
Set Tbl = db.OpenRecordset("employees", dbOpenTable)
' Note that employees table is used below in creating the relation.
' Uncommenting the line below allows the code to work properly.
' Tbl.Close
Set Rel = db.CreateRelation("myrel")
Rel.Table = "Employees"
Rel.ForeignTable = "Orders"
Set Fld = Rel.CreateField("EmployeeID")
Fld.ForeignName = "EmployeeId"
Rel.Fields.Append Fld
' eError will occur on next line.
db.Relations.Append Rel
Keywords: kberrmsg kbprb KB195837