Class ModelRelationship (Excel VBA)
The class ModelRelationship represents a relationship, currently in the data model, between two tables.
To use a ModelRelationship class variable it first needs to be instantiated, for example
Dim mtcForeignKeyColumn As ModelTableColumn: Set mtcForeignKeyColumn = Dim mtcPrimaryKeyColumn As ModelTableColumn: Set mtcPrimaryKeyColumn = Dim mdl As Model: Set mdl = Dim mrel As ModelRelationship Set mrel = mdl.ModelRelationships.Add(ForeignKeyColumn:=mtcForeignKeyColumn, PrimaryKeyColumn:=mtcPrimaryKeyColumn)
Here is an example of processing the ModelRelationship items in a collection.
Dim mdl As Model: Set mdl = Dim mrelModelRelationship As ModelRelationship For Each mrelModelRelationship In mdl.ModelRelationships Next mrelModelRelationship
The following procedures in this class have been grouped together and are described on a separate theme page
These are the main methods of the ModelRelationship class
Delete - Deletes the relationship.
ModelRelationships.Add - Adds a new relationship to the model.
Active when True, the relationship is active. When False, this relationship is inactive.
ForeignKeyTable contains the ModelTable object representing the table on the many side of the one-to-many relationship.
Parent returns an object that represents the parent object of the specified ModelRelationship object. Read-only.
PrimaryKeyTable contains the ModelTable object representing the table on the one side of the one-to-many relationship.
ModelRelationships.Count returns a Long value that represents the number of ModelRelationship objects in a ModelRelationships object.
ModelRelationships.Parent returns an object that represents the parent object of the specified ModelRelationships object. Read-only.