Public Sub AddRelation()
   Dim oRecRelation As CRecord
   'Varialble for Relationshp Record
   Dim ID As Long
  
   Set oRecRelation = New CRecord
   'Add the nonconstituent Relationship record
   With oRecRelation
       .Init REApplication.SessionContext
       .Fields(RECORDS_fld_FIRST_NAME) = "John"
       .Fields(RECORDS_fld_LAST_NAME) = "Doe"
       .Fields(RECORDS_fld_IS_CONSTITUENT) = False
       .Save
       'Get the ID to link the records later
       ID = .Fields(RECORDS_fld_ID)
       .CloseDown
   End With
   
   Set oRecRelation = Nothing
   'Open the Constituent Record
   Dim oMainRec As CRecord
   Set oMainRec = New CRecord
   oMainRec.Init REApplication.SessionContext
  
   oMainRec.Load 280
  
   Dim OInd As CIndividual2
   Set OInd = New CIndividual2
   OInd.Init REApplication.SessionContext

   With OInd
      .Fields(INDIVIDUAL2_fld_CONSTIT_ID) = oMainRec.Fields(RECORDS_fld_ID)
      .Fields(INDIVIDUAL2_fld_RELATION_ID) = ID
      .Fields(INDIVIDUAL2_fld_RECIP_RELATION_CODE) = "Father"
      .Fields(INDIVIDUAL2_fld_RELATION_CODE) = "Son"
      .Save
      .CloseDown
   End With
  
   Set OInd = Nothing
  
   oMainRec.CloseDown
   Set oMainRec = 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. 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.