Welcome to Forums Sign in | Join | Help | Forums
in Search


Split Gift Adjustments in VBA

Last post 07-20-2007 1:12 AM by Gary Hay. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-17-2007 7:55 PM

    Split Gift Adjustments in VBA

    Hi all, Would anyone know how to add adjustments to split gifts in VBA? See below for the code I have, but at the Validate instruction I get an error - Required field: Fund Id. Cheers, Gary Hay TWS Australia PS I hope the formatting is OK. ============================================================ Public Function AddAdjustment(objGift As Object, strDate As String, sngAmount As Single, strReason As String, strNotes As String) ' ' Author: Gary Hay ' Date Created: 11/05/2007 ' Request Tracker: ' SVN Version: ' Purpose: Add an adjustment to a gift. ' References: ' Reviewed By: ' Review Date: ' ' Author: Gary Hay ' Date Modified: 14/06/2007 ' Request Tracker: ' SVN Version: ' Purpose: Cater for adjusting a split gift ' Reviewed By: ' Review Date: ' Dim intSplitPointer As Integer Dim objAdjustment As IBBAdjustment Dim objAdjustmentServer As New CAdjustmentServer Dim objFund As New CFund With objAdjustmentServer .Init REApplication.SessionContext, objGift Set objAdjustment = .AddAdjustment() With objAdjustment ' set the fields on the adjustment .Fields(ADJUSTMENT_fld_Date) = Format(CDate(strDate), "dd/mm/yyyy") .Fields(ADJUSTMENT_fld_Amount) = sngAmount .Fields(ADJUSTMENT_fld_Reason) = strReason .Fields(ADJUSTMENT_fld_Notes) = strNotes If objGift.Splits.Count > 1 Then ' set the fields on the split adjustments, if any For intSplitPointer = 1 To objGift.Splits.Count .Splits.Add .Splits.Item(intSplitPointer).Fields(GIFTSPLIT_fld_Amount) = sngAmount .Splits.Item(intSplitPointer).Fields(GIFTSPLIT_fld_Fund) = objGift.Splits.Item(intSplitPointer).Fields(GIFTSPLIT_fld_Fund) .Splits.Item(intSplitPointer).Fields(GIFTSPLIT_fld_Appeal) = objGift.Splits.Item(intSplitPointer).Fields(GIFTSPLIT_fld_Appeal) .Splits.Item(intSplitPointer).Fields(GIFTSPLIT_fld_Campaign) = objGift.Splits.Item(intSplitPointer).Fields(GIFTSPLIT_fld_Campaign) Next intSplitPointer End If End With 'Validate and save the adjustment .Validate .Save End With System.SetToNothing objAdjustment, objAdjustmentServer End Function
  • 07-20-2007 1:12 AM In reply to

    Split Gift Adjustments in VBA

    Hi, Katie Hawes from Blackbaud has supplied the solution to split gift adjustments. Instead of the statements included in the If statement: If objGift.Splits.Count > 1 Then ' set the fields on the split adjustments, if any you can use this code: Dim oSplit As CGiftSplit For Each oSplit In .Splits oSplit.Fields(GIFTSPLIT_fld_Amount) = (sngAmount / .Splits.Count) Next oSplit The reason given is: When the .AddAdjustment is called the already original splits are automatically added to the adjustment. You will want to loop through the already existing and make any changes. Also I noticed that you are going to need to change the logic around the amount. The ADJUSTMENT_fld_Amount needs to be the new total for the gift and the GIFTSPLIT_fld_Amount will need to be set for each split so the total will equal the ADJUSTMENT_fld_Amount. Thanks to Katie.
Page 1 of 1 (2 items)