Public Sub SolicitorGift()

  Dim oGift As CGift

  Set oGift = New CGift

  oGift.Init REApplication.SessionContext

  'Load the gift

  oGift.Load 1541

  'Get the Assigned solicitors for the constituent

  Dim oSs As CAssignedSolicitors2

  Set oSs = New CAssignedSolicitors2

  oSs.Init REApplication.SessionContext, 818


  Dim os As CAssignedSolicitor2

  Dim gos As IBBRecordSolicitor



  For Each gos In oGift.Solicitors

   'Use to Constituent System Record ID of the Solicitor you want to remove

      If gos.Fields(RECORDSOLICITOR_fld_SolicitorId) = 190 Then

       'Remove the solicitor

           oGift.Solicitors.Remove gos

           Exit For

       End If

  Next gos

  'Loop through the assigned solicitors to find the one you want

  For Each os In oSs

       If os.Fields(ASSIGNEDSOLICITOR2_fld_ID) = 123 Then

          With oGift.Solicitors.Add

              'Add the solicitor to

              .Fields(RECORDSOLICITOR_fld_SolicitorId) = os.Fields(ASSIGNEDSOLICITOR2_fld_SOLICITOR_ID)

              .Fields(RECORDSOLICITOR_fld_Amount) = oGift.Fields(GIFT_fld_Amount)


              Exit For

          End With

      End If


  Next os

  Set os = Nothing


  Set oSs = Nothing



  Set oGift = Nothing

End Sub

Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Microsoft Visual Basic and the tools used to create and debug procedures. Our Customer Support can help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality. If you are interested in learning more about the VBA and API modules, contact your account manager.