Creating a One-to-Many Relationship
Sub CreateTblRelation() Dim cat As New ADOX.Catalog Dim fKey As New ADOX.Key On Error GoTo ErrorHandle cat.ActiveConnection = CurrentProject.Connection With fKey .Name = "fkPubId" .Type = adKeyForeign .RelatedTable = "Employee" .Columns.Append "EmpId" .Columns("Id").RelatedColumn = "PubId" End With cat.Tables("java2sTable").Keys.Append fKey MsgBox "Relationship was created." Set cat = Nothing Exit Sub ErrorHandle: cat.Tables("java2sTable").Keys.Delete "fkPubId" Resume End Sub
1. | Show all foreign tables from a relation | ||
2. | Create Relation |