Public Sub RescheduleSample()

   Dim oGift As CGift 'Gift to be rescheduled

   Set oGift = New CGift

   oGift.Init REApplication.SessionContext

   oGift.Load 1983


   Dim oTemp As CGift 'Temp gift used to schedule new installments

   Set oTemp = New CGift

   oTemp.Init REApplication.SessionContext


   Dim cPaid As Currency 'Sums the amount already paid before rescheduling

   cPaid = 0

   Dim cAmount As Currency

   cAmount = 4000 'Set this to the new pledge amount


   Dim oInst As CInstallment 'Object to hold installments


   For Each oInst In oGift.Installments 'Loop to remove unpaid installments

       If oInst.Fields(INSTALLMENT_fld_Balance) = Val(oInst.Fields(INSTALLMENT_fld_Amount)) Then

           oGift.Installments.Remove oInst 'Removes unpaid installments


           cPaid = cPaid + oInst.Fields(INSTALLMENT_fld_Amount) 'Summing amount already paid

       End If

       Set oInst = Nothing

   Next oInst


   With oTemp 'Temp gift used to schedule new installments

       .Fields(GIFT_fld_Amount) = cAmount - cPaid

       .Fields(GIFT_fld_Installment_Frequency) = "Monthly"

       .Fields(GIFT_fld_Number_of_Installments) = 14 'Number of installments to add

       .Fields(GIFT_fld_Date_1st_Pay) = "7/10/2009" 'Must be greater than the last payment

       .Fields(GIFT_fld_Schedule_Spacing) = 1

       .Fields(GIFT_fld_Type) = "Pledge"

       .Fields(GIFT_fld_Schedule_MonthlyOrdinal) = "First"

       .Fields(GIFT_fld_Schedule_MonthlyDayOfWeek) = "Monday"


   End With


   For Each oInst In oTemp.Installments 'Adds the installments generated from the temp gift to the pledge

       With oGift.Installments.Add

           .Fields(INSTALLMENT_fld_Amount) = oInst.Fields(INSTALLMENT_fld_Amount)

           .Fields(INSTALLMENT_fld_Date) = oInst.Fields(INSTALLMENT_fld_Date)

       End With

       Set oInst = Nothing

   Next oInst


   oGift.Fields(GIFT_fld_Amount) = cAmount



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