Does the IDE generate receipt numbers when a gift is created?

When a gift is created, receipt numbers are generated. These are automatically generated within the application and the API can be used to obtain the next available receipt number. This solution contains an example in code to retrieve this number.
The API has no built-in function to generate receipt numbers.  The following VBA/VB6 code can be used to obtain the largest number:

Public Sub GreatestRecieptNumber()
    Dim lGreatestReceiptNumber As Long
    Dim oGifts As CGifts
    Set oGifts = New CGifts
    Dim oGift As CGift
    
    With oGifts
        .Init REApplication.SessionContext
        .SortField = GIFT_fld_Receipt_Number
        .SortOrder = Descending
        Set oGift = .Item(1)
    End With

    lGreatestReceiptNumber = oGift.Fields(GIFT_fld_Receipt_Number)
    
    Debug.Print lGreatestReceiptNumber 'prints the largest receipt number
    
    oGift.Closedown
    oGifts.Closedown
    Set oGift = Nothing
    Set oGifts = Nothing
    
End Sub


VBA/API
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.
 

Environment

 VBA/API

Was this article helpful?