Class ModelRelationship (Excel VBA)

The class ModelRelationship represents a relationship, currently in the data model, between two tables.

The main procedures of class ModelRelationship are Delete and ModelRelationships.Add

Set

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)

The following procedures can be used to set variables of type ModelRelationship: ModelRelationships.Item, ModelRelationships.Add and Model.ModelRelationships

For Each

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

Themes

The following procedures in this class have been grouped together and are described on a separate theme page

Column with its procedures ForeignKeyColumn and PrimaryKeyColumn

Methods

These are the main methods of the ModelRelationship class

Delete - Deletes the relationship.

ModelRelationships.Add - Adds a new relationship to the model.

Properties

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.