Private Sub EditAdjustment_Payment()

   'This example edits the adjustment we just added, adds a note, changes the amount to $24, and changes

   'the installments being paid from $25 to the third installment to $11 to the third and $13 to the fourth

   'installments.  Note that in doing so, we effectively lose the audit trail of a $25 payment to the third

   'installment - the audit trail shows that it was originally a $20 payment to the first installment.


   Dim lPledgeId As Long

   Dim lPaymentId As Long

   Dim oPledge As CGift

   Dim oPayment As CGift

   Dim oAdjustment As IBBAdjustment

   Dim oAdjustmentServer As CAdjustmentServer


   On Error GoTo eh


   lPledgeId = 355

   lPaymentId = 356


   Set oPledge = New CGift

   With oPledge

       .Init goSessionContext

       .Load lPledgeId


       Set oPayment = New CGift

       With oPayment

           .Init goSessionContext

           .Load lPaymentId


           Set oAdjustmentServer = New CAdjustmentServer

           With oAdjustmentServer

               .Init goSessionContext, oPayment


               Set oAdjustment = .EditAdjustment(oPayment.Adjustments.Item(1))

               With oAdjustment


                   'let the user edit fields on the adjustment

                   .Fields(ADJUSTMENT_fld_Notes) = "Oops - forgot to add the note!"

                   .Fields(ADJUSTMENT_fld_Amount) = 24


                   'Note that the PledgePayer on an adjustment for a payment automatically gets loaded with the

                   'applications for the payment being adjusted.  This is provided both as a convenience for the

                   'cases where the payment amount and  payment applications are not going to be changed by the

                   'adjustment, as well as a method of validation in case the amount changes but is not re-distributed

                   'across installments.  Note that we call RemovePledge to first remove the existing applications,

                   'since in this example we are changing the installment being paid (we could also use

                   'RemoveInstallment method if the InstallmentId were known).

                   With .PledgePayer

                       .RemovePledge lPledgeId

                       .ApplyToInstallment oPledge.Installments.Item(3), 11

                       .ApplyToInstallment oPledge.Installments.Item(4), 13

                   End With

               End With


               'now we can save the adjustment




           End With

           Set oAdjustmentServer = Nothing



       End With

       Set oPayment = Nothing



   End With

   Set oPledge = Nothing


   Exit Sub



   If Not oPayment Is Nothing Then


       Set oPayment = Nothing

   End If


   If Not oPledge Is Nothing Then


       Set oPledge = Nothing

   End If


   If Not oAdjustmentServer Is Nothing Then


       Set oAdjustmentServer = Nothing

   End If


   MsgBox Err.Description, vbInformation, goSessionContext.MsgBoxCaption

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.