The BeforeSave Event
The BeforeSave event fires before any Save operation is performed (Save, Save and New, Save and Close). With
this, you can enforce any Business Rule specific to your organization.
The event passes an oRecord that represents the active object and bCancel that, if set to True, cancels the save
operation and returns focus to the active form. The oRecord object is already initialized, so there is no need to call
the Init method or the CloseDown method at the end of your subroutine.
After the code is complete, TheRaiser’s Edge still performs the usual validation to guarantee all required fields are
completed and date fields contain valid dates.
This code sample determines if a donation qualifies the constituent as a Major Donor and determines if the Director
of Development needs to be notified. The code below is placed in the BeforeSave() event of the ActiveGift object.
Private Sub Gift_BeforeSave(oRecord As Object, bcancel As Boolean)
'Before we save the gift record,
' 1) Determine if this will make the person a Major Donor
' by checking the amount given
' 2) See if we need to mark the constituent record with
' the Constituent Code, Major Donor
' 3) Check the MajorDonor.Mdb to see if the Director of
' Development needs to be notified
' The module level variables, mbAddMajorDonorCC and mbNotifyDOD
' will be used in the After_Save event
Dim bHasMajorDonorCC As Boolean
Dim oGift As CGift
Dim oConstituentCode As CConstituentCode
'This is not necessary, but allows you to use the Intellisense
' feature, which you don't get with the late bound oRecord.
Set oGift = oRecord
If oGift.Fields(GIFT_fld_Amount) > 1000 Then
'Look through the person's constituent codes to see if they are
' marked as a major donor
For Each oConstituentCode In oGift.Constituent.ConstituentCodes
If oConstituentCode.Fields(CONSTITUENT_CODE_fld_CODE) = _
"Major Donor" Then
bHasMajorDonorCC = True