Public Sub GetConstitFromUser()

   Dim oSession As IBBSessionContext

   Dim oRecords As CRecords

   Dim oRecord As CRecord

   Dim sSQL As String

   

   Set oSession = REApplication.SessionContext

   

   'select the constituent ID of the user using the session context

   sSQL = "ID in (Select ConstituentID from Users where User_ID = " & oSession.CurrentUserID & ")"

   

   Set oRecords = New CRecords

   oRecords.Init oSession, tvf_record_CustomWhereClause, sSQL

   

   'if the user is linked to a constituent record, print the constituent ID

   If oRecords.Count = 1 Then

       For Each oRecord In oRecords

           Debug.Print oRecord.Fields(RECORDS_fld_FULL_NAME) & " " & "-" & " " & _

            oRecord.Fields(RECORDS_fld_CONSTITUENT_ID)

           oRecord.Closedown

           Set oRecord = Nothing

       Next oRecord

   End If

   

   oRecords.Closedown

   Set oRecords = 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.