Public Sub AddIndividualRelationship()
''This example will add an individual Sister relationship to constituent Robert Hernandez
''with a a reciprocal relationship of Brother

  Dim oRec As CRecord
  Dim lID As Long
  Dim oRelation As CRecord
  Dim oInd As CIndividual2

  Set oRec = New CRecord
  oRec.Init REApplication.SessionContext

  'load Robert Hernandez in sample data
  oRec.Load 280

  'create a new relationship record
  Set oRelation = New CRecord
  With oRelation
      .Init REApplication.SessionContext
      .Fields(RECORDS_fld_IS_CONSTITUENT) = False
      .Fields(RECORDS_fld_LAST_NAME) = "Hernandez"
      .Fields(RECORDS_fld_FIRST_NAME) = "Jane"
      .Fields(RECORDS_fld_TITLE_1) = "Mrs."
      .Save

      lID = oRelation.Fields(RECORDS_fld_ID)
   End With

   'add Relationship to constituent
   Set oInd = New CIndividual2
   oInd.Init REApplication.SessionContext

   With oInd
       .Fields(INDIVIDUAL2_fld_CONSTIT_ID) = oRec.Fields(RECORDS_fld_ID)
       .Fields(INDIVIDUAL2_fld_RELATION_ID) = lID
       .Fields(INDIVIDUAL2_fld_RECIP_RELATION_CODE) = "Brother"
       .Fields(INDIVIDUAL2_fld_RELATION_CODE) = "Sister"
       .Save
   End With

  'Cleanup
   oRec.CloseDown
   Set oRec = Nothing
   oInd.CloseDown
   Set oInd = Nothing
   oRelation.CloseDown
   Set oRelation = 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. 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.