As you can probably tell this is pretty old code before the Set Field_RelatedField property. I would re-write this now.