Public Sub ApplyPledge()

   

   Dim oRec As CRecord

   Set oRec = New CRecord

   oRec.Init REApplication.SessionContext

   

   'load the constituent

   oRec.Load 677

   

   Dim oGift As CGift

   

   Dim oPledge As CGift

   Set oPledge = New CGift

   oPledge.Init REApplication.SessionContext

   'load the pledge

   oPledge.Load 1279

   

   

   'Loop through the gifts in the constituent record to see if they should be

   'applied to the loaded pledge

   For Each oGift In oRec.Gifts

       If oGift.Fields(GIFT_fld_Type) = "Cash" Then

       If oGift.Fields(GIFT_fld_Fund) = oPledge.Fields(GIFT_fld_Fund) Then

           oGift.PledgePayer.ApplytoPledge oPledge, oGift.Fields(GIFT_fld_Amount)

           'save the gift

           oGift.Save

       End If

       End If

       oGift.CloseDown

   Next oGift

  MsgBox "Gift is Applied"



Set oGift = Nothing

oRec.CloseDown

Set oRec = Nothing



oPledge.CloseDown

Set oPledge = 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.