finding in underlying model

N

Nate Russell

I have a question similar to Kevin's a few below:

I have a foreign key relationship that has somehow been
deleted from the diagram but not the underlying model
(Visio 2002/2003 for Enterprise Architects). It gives me
a error that refuses to let me generate DDL code. I can
double click the error and see the foreign key
properties, but have found no way to completely remove it
from the underlying model.
 
G

Guest

This was posted a long time ago. It has been very helpful
to me.

Use the following VB script to eliminate the offending
relationship. Follow the instruction in the comment.

' This is provided "AS IS" with no warranties, and
' confers no rights.
'
' This module removes all relationships that are NOT fully
connected
' to either parent table or child table. The relationship
may or may
' not visible. If you get
' filename : error L2100: FK name : Relationship is
not fully connected.
' error messages and not able to locate it on the diagram,
then this module
' will remove the relationships from the model.
'
' Follow the following steps
'
' Select "Tools"/"Macros"/"Visual Basic Editor" from
the Visio menus.
' Select "Tools"/"References" from the Visual Basic
editor.
' Check "Microsoft Visio Database Modeling Engine Type
Library" and
' click the OK button.
' Copy this following subroutine into the text area
under "(General)"
' Select "Run"/"Run Sub-UserForm" (or hit the play
button)
' Close the Visual Basic editor
' Now select "Database"/"Model"/"Error Check"
'
Sub DeleteAllDisconnectedRelationshipsFromAllModels()

Dim vme As New VisioModelingEngine
Dim models As IEnumIVMEModels
Dim model As IVMEModel
Dim elements As IEnumIVMEModelElements
Dim element As IVMEModelElement
Dim relationship As IVMERelationship

Set models = vme.models
Set model = models.Next

Do While Not model Is Nothing
Set elements = model.elements
Set element = elements.Next

Do While Not element Is Nothing
If (element.Type = eVMEKindERRelationship) Then
Set relationship = element

If (Not relationship.IsFullyConnected) Then
model.DeleteElement element.ElementID
Set elements = model.elements
End If
End If

Set element = elements.Next
Loop

Set model = models.Next
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top