Private Sub AddTableEntry()
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 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) = "Clubs" 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 sClub As String
sClub = "Ritz"

If ocodetableserver.GetTableEntryID(sClub, lID) = 0 Then
omsgbox = MsgBox("Do you want to add '" & sClub & "' to the " & _
ocodetableserver.TABLENAME(lID) & " table?", vbYesNo)
Select Case omsgbox
Case vbYes
otablelookuphandler.AddEntry True, lID, , sClub
Case vbNo
Debug.Print "Nothing"
End Select
End If

oTEs.Closedown
Set oTEs = Nothing

Set oTE = Nothing

ocodetableserver.Closedown
Set ocodetableserver = Nothing

otablelookuphandler.Closedown
Set otablelookuphandler = Nothing

REService.Closedown
Set REService = Nothing

End Sub