Removing dead relations in Visio 2003

S

Simon Storr

Having an issue with relations in a Visio 2003 ERD. If you delete a relation
but don't select 'remove from underlying model' it just sits there
generating an error when you do an error check. I can't find any way of
removing it as you can't seem to get at it anywhere once its off the
diagram. The only way I've found is to select all and paste to a new diagram
which is a pain :eek:( Is there a way to get rid of this phantom relation?

TIA

Simon
 
S

Scot Becker

Hi Simon,
Having an issue with relations in a Visio 2003 ERD. If you delete a relation
but don't select 'remove from underlying model' it just sits there
generating an error when you do an error check. I can't find any way of
removing it as you can't seem to get at it anywhere once its off the
diagram. The only way I've found is to select all and paste to a new diagram
which is a pain :eek:( Is there a way to get rid of this phantom relation?

Are you using Pro or Enterprise Architect? I tried to reproduce this in
Enterprise Architect 2003 but couldn't (in other words, they finally fixed
it), but I don't know about Pro.

The only other way to remove these is by interrogating the API via VBA or
something. Chang Oh had a post a while back with the VBA code; you'll want
to google for it.

Hope that helps,
Scot.
................................................
Scot Becker

Orthogonal Software
www.orthogonalsoftware.com

ORM Blog: www.objectrolemodeling.com
 
H

Henrik J.

Hi,

I've tried to search google for that code you were
describing Scot, with no luck...
Is there any chance that you know where to find it?
It would really help me a lot

Thanks
Henrik
 
S

Scot Becker

Hi Henrik,
I've tried to search google for that code you were
describing Scot, with no luck...
Is there any chance that you know where to find it?
It would really help me a lot

Here is the post from Chang:

Chang Oh said:
You can run 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

................................................
Scot Becker

Orthogonal Software
www.orthogonalsoftware.com

ORM Blog: www.objectrolemodeling.com
 

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