RE-Decoded

A technical look at the Raiser's Edge API from Blackbaud


Feeds:

Removing from a collection

August 29th, 2008 by David Zeidman

One issue I had when I first started was how do I remove a child object from a collection. For example if I want to remove one constituent code from a constituent I need to loop through them, find the one I want to remove and remove it. My fear though was that if I simply remove it whilst looping won’t I mess up the collection? This can happen in some classes.

Apparently not with RE collections. You are able to loop and remove and not affect the collection. Here is the simple code to remove a constituent code:

Public Sub RemoveConCode(oRecord As IBBDataObject)
   Dim oConstit As CRecord
   Dim oConCode As CConstituentCode

   If TypeOf oRecord Is CRecord Then
      Set oConstit = oRecord

      For Each oConCode In oConstit.ConstituentCodes
         If oConCode.Fields(CONSTITUENT_CODE_fld_LONG_DESC_READONLY) = "To delete" Then
            oConstit.ConstituentCodes.Remove oConCode
         End If
      Next
   End If

End Sub

Posted in Beginner | No Comments »

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Switch to our mobile site