Public Sub AddOrgRelationship()

'load Robert Hernandez constituent record from sample data
Dim oCon As CRecord
Set oCon = New CRecord
oCon.Init REApplication.SessionContext
oCon.LoadByField uf_Record_CONSTITUENT_ID, 96

Dim lId As Long
lId = oCon.Fields(RECORDS_fld_ID)

'load AAA Concrete organization record
Dim oCon2 As CRecord
Set oCon2 = New CRecord
oCon2.Init REApplication.SessionContext
oCon2.LoadByField uf_Record_CONSTITUENT_ID, 163

Dim lID2 As Long
lID2 = oCon2.Fields(RECORDS_fld_ID)

Dim oOrgRel As COrganization2
Set oOrgRel = New COrganization2

With oOrgRel
   .Init REApplication.SessionContext
   .Fields(ORGANIZATION2_fld_CONSTIT_ID) = lId
End With

Set oOrgRel = Nothing
Set oCon2 = Nothing
Set oCon = Nothing

End Sub

Additional related articles:
How do I write code that creates an organizational relationship on an individual, but is not reciprocated?

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.