Say you’ve just built a Geodatabase. Maybe from a Visio UML schema, maybe some other way. On detailed inspection you’ve found that either the forward or backward path label on one of your relationships is wrong. (As might happen if you’ve copied/pasted relationship definitions in your Visio and not changed the path labels.)
Now these labels are just as their name implies, “labels”. Kind of like an alias name on a feature class or a field. Difference is that you can’t change the label through the ArcCatalog user interface.
So… from here you could delete and re-create the relationship. Or go back to the beginning and re-create the Geodatabase (if this came from Visio you should certainly update the Visio model.) But, if it’s really inconvenient to do this, then ArcObjects offers a method to change the label. Add the VBA code below to your ArcCatalog, connect it to a button and give it a go.
Private Sub AlterRelationshipLabels()
Dim gxApp As IGxApplication
Dim gxObject As IGxObject
Set gxApp = Application
Set gxObject = gxApp.SelectedObject
' make sure something is selected
If (Not (gxObject Is Nothing)) Then
' make sure data is selected
If (Not TypeOf gxObject Is IGxDataset) Then
MsgBox "Selected object is not a relationship class", vbInformation
Else
Dim gxDataset As IGxDataset
Set gxDataset = gxObject
Dim dataset As IDataset
Set dataset = gxDataset.dataset
If gxDataset.Type <> esriDTRelationshipClass Then
MsgBox "Selected object is not a relationship class", vbInformation
Else
Dim relClass As IRelationshipClass
Set relClass = dataset
Dim relClassEdit As IRelClassSchemaEdit
Set relClassEdit = relClass
Dim vbResponse As VbMsgBoxResult
Dim sLabel As String
vbResponse = MsgBox("Old forward path label: " & relClass.ForwardPathLabel & _
" Change it? ", vbYesNo)
If (vbResponse = vbYes) Then
sLabel = InputBox("Enter new forward path label:", "Forward Path Label")
relClassEdit.AlterForwardPathLabel sLabel
End If
vbResponse = MsgBox("Old backward path label: " & relClass.BackwardPathLabel & _
" Change it? ", vbYesNo)
If (vbResponse = vbYes) Then
sLabel = InputBox("Enter new backward label:", "Backward Path Label")
relClassEdit.AlterBackwardPathLabel sLabel
End If
End If
End If
End If
End Sub