Private Sub AddEmailPhoneType()
''This is an example of adding an email address "phone" type available on the UI as Config > Tables > Phone 

Types
''Using the IBBTableLookupHandler2 as the Extension to the CTableLookupHandler class
''This was introduced in RE 7.94

Dim oTables As CCodeTables
Set oTables = New CCodeTables
oTables.Init REApplication.SessionContext

Dim reservice As REServices
Set reservice = New REServices
reservice.Init REApplication.SessionContext

Dim oCodeTableServer As CCodeTablesServer
Set oCodeTableServer = reservice.CreateServiceObject(bbsoCodeTablesServer)
oCodeTableServer.Init REApplication.SessionContext

Dim oTablelookupHandler As CTableLookupHandler
Set oTablelookupHandler = reservice.CreateServiceObject(bbsoTableLookupServer)
oTablelookupHandler.Init REApplication.SessionContext

Dim oTableLookupExt As IBBTableLookupHandler2
Set oTableLookupExt = oTablelookupHandler

Dim oTable As CCodeTable
Dim lID As Long
'Loop through the tables to find the one you need
    For Each oTable In oTables
        If oTable.Fields(ctfNAME) = "Phone Types" Then
        'Get the ID
        lID = oTable.Fields(ctfCODETABLEID)
    Exit For
        End If

oTable.Closedown
Next oTable
oTables.Closedown
Set oTables = Nothing
Set oTable = Nothing

'Load the collection of table entries for the requested table
Dim oTEs As CTableEntries
Set oTEs = New CTableEntries
oTEs.Init REApplication.SessionContext, lID

'Get a count of table entries
Debug.Print oTEs.Count

Dim oTE As CTableEntry

Dim Success As Boolean
Dim sEmail As String
sEmail = "Email Test"

If oCodeTableServer.GetTableEntryID(sEmail, lID) = 0 Then
omsgbox = MsgBox("Do you want to add '" & sEmail & "' to the " & _
oCodeTableServer.TABLENAME(lID) & " table?", vbYesNo)

Select Case omsgbox
Case vbYes
With oTableLookupExt
    'AddPhoneEntry function - Adds a new phone entry to the lookup table.
    'staticentryPhoneTypeEmailAddress=3
    'staticentryPhoneTypeFaxNumber=2
    'staticentryPhoneTypeOther=5
    'staticentryPhoneTypeTelephoneNumber=1 (default)
    'staticentryPhoneTypeWebAddressUrl=4
    .AddPhoneEntry True, sEmail, 3 ''Description=Email Test, Phone number type=Email Address
End With
Case vbNo
    Debug.Print "Nothing"
End Select

End If

''Cleanup
oTEs.Closedown
Set oTEs = Nothing
Set oTE = Nothing
oCodeTableServer.Closedown
Set oCodeTableServer = Nothing
oTablelookupHandler.Closedown
Set oTablelookupHandler = Nothing
Set oTableLookupExt = Nothing
reservice.Closedown
Set reservice = 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.