We are a group of users of Blackbaud products and are not affiliated with Blackbaud. We'd love to have you join our community to help and be helped in getting the most from your Blackbaud software.
Register now to join us to get independant advice on your system, connect with 3rd party consultants to help you maximize your database and have a real alternative to the official Blackbaud website.
Does anyone know how to use VBA to roll back the date of a recurring gift record?
The most likely looking way of doing this is the RollbackTransaction method for a CGift record but it gives an error:
Run-time error '-2147219866 (80040666)' Object variable or With block variable not set.
The objGift.Fields(GIFT_fld_NextTransactionDate) field is read-only.
We can't find any documentation on what the objGift.NextRecurringTransactionDate function is supposed to do, but can't make it change the date.
Here's our code. What are we doing wrong?
By the way, replacing the objGift.RollbackTransaction with an objGift.SkipNextTransaction does indeed skip a transaction.
Thanks in advance for any help,
David Wanless
The Wilderness Society (Australia)
david dot wanless at wilderness dot org dot au
Public Function RollbackTransaction(lngConstituentID As Long)
'
' Author: David Wanless
' Date Created: 2/3/07
' Request Tracker:
' Purpose: Roll back transaction for a given constituent
' Reviewed By:
' Review Date:
'
Dim blnReturnValue As Boolean
Dim intRecordCount As Integer
Dim intGiftCount As Integer
Dim intFieldCount As Integer
Dim intTableId As Integer
Dim intEntryId As Integer
Dim lngGiftId As Long
Dim objConstituent As New CRecord
Dim objConstituentRG As New CRecord
Dim objGift As New CGift
lngGiftId = 0
For Each objGift In objConstituent.Gifts
If objGift.Fields(GIFT_fld_Type) = "Recurring Gift" Then
lngGiftId = objGift.Fields(GIFT_fld_ID)
' objGift.Fields(GIFT_fld_NextTransactionDate) = CDate("28/02/2007")
' objGift.NextRecurringTransactionDate( - don't know what this does
objGift.RollbackTransaction
objGift.Fields(GIFT_fld_Reference) = "Rolled back by VBA on " & Format(Date, "dd/mm/yyyy")
objGift.Save
objGift.CloseDown
objGift = Nothing
blnReturnValue = True
End If
Next objGift
End If
objConstituent.CloseDown
Set objConstituent = Nothing
Haven't really had the time to look through your code properly but the line:
objGift.NextRecurringTransactionDate
gets the next recuring transaction date after the date that you supply. If you supply the previous date it will simply give you the same date back so you have to supply the date plus one day. However this method is pointless if all you want is the next scheduled transaction date as it is stored in the gift.
objGift.Fields(GIFT_fld_NextTransactionDate)
By the looks of things you are trying to rollback a transaction that is not the latest one. Only the latest transaction can be rolled back (that is how it is in the GUI)
Thanks for that. At least I now know what objGift.NextRecurringTransactionDate does.
However, the fundamental problem was that objGift.RollbackTransaction doesn't work. All we want to do is roll back the most recent transaction, but we get the error quoted when we try. Have you (or any other readers) ever managed to get RollbackTransaction to work?
Those two commented lines about objGift.NextRecurringTransactionDate and objGift.NextRecurringTransactionDate were only in there because I was exploring alternatives when I couldn't get RollbackTransaction to work.