Removing from a collection
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 message 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
Related posts:
- Custom user defined business rules The idea of creating user defined business rules has been...
- The Full Address I wanted to be able to get a constituent's address...
- Describe a constituent in their dialogue window When you open up a constituent record wouldn't it be...
Posted in Beginner |