Public Function AddTableEntry(ByVal lCodeTableID As Long, ByVal sDesc As String, Optional ByVal sShort As String = "") As Long

   'This procedure adds a new code table entry and returns its ID

   Dim oTableEntry As CTableEntry

   If Len(Trim$(sDesc)) > 0 Then

       Set oTableEntry = New CTableEntry

       With oTableEntry

           .Init REApplication.SessionContext

           .Fields(tableentry_fld_CODETABLESID) = lCodeTableID

           .Fields(tableentry_fld_LONGDESCRIPTION) = Left$(sDesc, 50)

           If Len(sShort) > 0 Then

               .Fields(tableentry_fld_SHORTDESCRIPTION) = Left$(sShort, 5)

           End If


           AddTableEntry = Val(.Fields(tableentry_fld_TABLEENTRIESID))


       End With

       Set oTableEntry = Nothing

   End If

End Function

Public Sub Entry()

   Dim sLDes As String


   sLDes = "Boston"


   Dim lID As Long

   'Call the function

   lID = AddTableEntry(tbnumCountry, sLDes, sLDes)


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.