Deleting relationship

K

Kim

I am using the following code to delete the relationships from a db:

For Each relationship In dbSlave.Relations
dbSlave.Relations.Delete relationship.Name
Next

The problem is that all relationships are deleted, but one. There is
nothing special about the relationship, because if I run the code again on
the relationship remaining, it is deleted. Anyone have any ideas?

Thanks!
 
V

Van T. Dinh

The problem is that the Relationship Collection is re-indexed as soon as you
delete a Relationship and therefore the For ... Next loop will missed every
2nd relationship.

You need to count the number of relationship and delete from the
highest-indexed relationship first to the lowest-indexed relationship last.
 
Top