Public Sub AddSpouseAndRelationship()

   Dim oInd As CIndividual2
   Set oInd = New CIndividual2
   oInd.Init REApplication.SessionContext
   
   Dim oInd2 As CIndividual2
   Set oInd2 = New CIndividual2
   oInd2.Init REApplication.SessionContext

   With oInd
       .Fields(INDIVIDUAL2_fld_CONSTIT_ID) = 3262587
       .Fields(INDIVIDUAL2_fld_RELATION_CODE) = "Accountant"
       .Fields(INDIVIDUAL2_fld_RECIP_RELATION_CODE) = "Client"
       .Fields(INDIVIDUAL2_fld_RELATION_ID) = 3262589
       .Fields(INDIVIDUAL2_fld_RECIPROCATE) = -1
       .Save
   End With

   With oInd2
      .Fields(INDIVIDUAL2_fld_CONSTIT_ID) = 3262587
      .Fields(INDIVIDUAL2_fld_RELATION_CODE) = "Spouse"
      .Fields(INDIVIDUAL2_fld_RECIP_RELATION_CODE) = "Spouse"
      .Fields(INDIVIDUAL2_fld_RELATION_ID) = 3262589
      .Fields(INDIVIDUAL2_fld_RECIPROCATE) = -1
      .Fields(INDIVIDUAL2_fld_IS_SPOUSE) = -1
      .Save
   End With
   
   oInd2.CloseDown
   oInd.CloseDown
   Set oInd = Nothing
   Set oInd2 = 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.