Example 1
In this code sample, a date attribute is added to a gift.

Private Sub AddAttributetoGift()

   Dim lAttID As Long
   Dim oGift As CGift
   Dim oServices As REServices
   Dim oATS As CAttributeTypeServer
   Set oServices = New REServices
   oServices.Init REApplication.SessionContext

   'Get the ID of the attribute that will be added
   Set oATS = oServices.CreateServiceObject(bbsoAttributeTypeServer)
   oATS.Init REApplication.SessionContext
   lAttID = oATS.GetAttributeTypeID("Deposit Date", bbAttributeRecordType_GIFT)
   Set oATS = Nothing
   Set oServices = Nothing  

   Set oGift = New CGift
   oGift.Init REApplication.SessionContext

   'using system record id to load the gift
   oGift.Load 1644

   'Adding attribute to the gift
   With oGift.Attributes.Add
       .Fields(Attribute_fld_ATTRIBUTETYPES_ID) = lAttID
       .Fields(Attribute_fld_VALUE) = "1/1/2007"
   End With

  Set oGift = Nothing

End Sub

Example 2
In this code sample, a label with the attribute category (in this case “Special Mailing Info”) and either a combo box (if the attribute data type is table or boolean) or a text box (for all other data types) is displayed.

Option Explicit

Private moCodeTablesServer As CCodeTablesServer
Private moAttributeTypeServer As CAttributeTypeServer

Private Sub Form_Load()

Dim lAttribute_ID As Long
Dim bOnlyOneAllowed As Boolean

REService.CreateServiceObject (bbsoCodeTablesServer)
Set moCodeTablesServer = New CCodeTablesServer
moCodeTablesServer.Init REApplication.SessionContext

REService.CreateServiceObject (bbsoAttributeTypeServer)
Set moAttributeTypeServer = New CAttributeTypeServer
moAttributeTypeServer.Init REApplication.SessionContext

With moAttributeTypeServer

lAttribute_ID = .GetAttributeTypeID("Special Mailing Info", _

Label1.Caption = .GetAttributeTypeDescription(lAttribute_ID)

'bOnlyOneAllowed will now be True or False depending on if this
' Attribute is allowed to be present more than once per record
Select Case .GetAttributeDataType(lAttribute_ID, bOnlyOneAllowed)
'If the Data Type is Boolean than we add Yes and No to the Combo box
Case bbAttribute_BOOLEAN
Combo1.Visible = True
Combo1.AddItem "Yes"
Combo1.AddItem "No"

Case bbAttribute_TABLEENTRY
Combo1.Visible = True
'This uses the CodeTablesServer to the load the combo
' with all of the table entries
moCodeTablesServer.LoadCombo Combo1, _
.GetAttributeCodeTableID(lAttribute_ID), , True

Case Else
Text1.Visible = True

End Select

End With

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. Blackbaud Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.