EBDN - Community - Question & Answers

  1. Zarko Mocnik
  2. VBA Development
  3. Sunday, 04 October 2020
How to store changes in Cable.Destinations?

As an experiment I tried the following code (before starting cable and some unit have to be selected) to print existing cable destinations, then delete the first one and set the another one.

In watch window everything looks as expected (existing destination is deleted and after AddNew new is added), but after exiting sub information is not stored into database.

Sub test()
Dim cb As Cable
Dim dest As CableDestination
Set cb = Selection(1)
For Each dest In cb.Destinations
If Not dest.RelatedObject Is Nothing Then
Debug.Print dest.LeftSide, dest.ManualEntry, dest.RelatedObject.ReferenceName
End If

Call cb.Destinations.Remove(1)
Call cb.Destinations.AddNew(Selection(2), True)
Call cb.Store
End Sub