When using the CGift object, it is looking at the hard credit gifts a constituent has made. In order to look at soft credits or matching gifts, go through the CGifts object and use its filter object. The following sample code uses the filter object on the CGifts top level collection.  Note the use of the tvf_Gift_UseFilterObject flag, which instructs the oGifts collection to consider params established on the filter object.  Note also the use of the bReadOnlyMode flag, which could speed up your program when creating this collection (the objects will be in readonly mode).


Public Sub ViewSoftCredits()

   Dim oGifts As CGifts

   Dim oGift As CGift

   Set oGifts = New CGifts

   oGifts.Init REApplication.SessionContext, tvf_Gift_UseFilterObject, bReadOnlyMode:=True

   With oGifts.FilterObject

       .ConstitRecordID = 744

       .MatchCredit = staticentry_DefaultMGCredit_Both 'Allows for three different options

       .SoftCredit = staticentry_DefaultSCCredit_Both 'Allows for three different options

       .SoftCreditAmountMethod = staticentry_SCMethod_UseAmountinGrid 'Allows for three different options

   End With


   'Count could change if .MatchCredit or .SoftCredit have different values

   MsgBox oGifts.Count


   'looping through all matching gifts

   For Each oGift In oGifts

       With oGift

           Debug.Print .Fields(GIFT_fld_Constituent_Name) & " - " & _



       End With

   Next oGift

   Set oGift = Nothing



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