Public Sub AddDebitGift()

   'Get the banks for the constituent

   Dim oBanks As CFinancials2

   Set oBanks = New CFinancials2

   oBanks.Init REApplication.SessionContext, 280


   Dim lbankID As Long


   Dim oBank As CFinancial2

   'Make sure the constituent has banks

   If oBanks.Count > 0 Then

   'Loop through the banks and find the one you want and get the ID

   For Each oBank In oBanks

       If oBank.Fields(FINANCIAL2_fld_NAME) = "Federal Credit Union" Then

        lbankID = oBank.Fields(FINANCIAL2_fld_ID)

        End If


   Next oBank


       MsgBox "This constituent has no bank information"

       Exit Sub

   End If


   Dim oGift As CGift

   Set oGift = New CGift


   With oGift

       .Init REApplication.SessionContext

       .Fields(GIFT_fld_Fund) = "Acquisition Fund"

       .Fields(GIFT_fld_Amount) = 451

       .Fields(GIFT_fld_Date) = Now

       .Fields(GIFT_fld_Constit_ID) = 280

       .Fields(GIFT_fld_Payment_Type) = "Direct Debit"

       .Fields(GIFT_fld_ConstituentBankId) = lbankID

       'save the gift



   End With


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.