Public Sub RenewMember()

   Dim oMember As CMembership
   Dim lProgID As Long
   Dim lCatID As Long
   Dim oCat As CMemCat
   Dim oCats As CMemCats
   Dim oCodeTableServer As CCodeTablesServer

   Set oCodeTableServer = New CCodeTablesServer
   oCodeTableServer.Init REApplication.SessionContext

   Set oMember = New CMembership
   oMember.Init REApplication.SessionContext
   oMember.Load 1  'or what ever id the membership is

   'if you want to renew and use the same category and program information then
   'get the information before adding a new transaction
   lCatID = oMember.Transactions.Item(1).Fields(MEMBERSHIPTRANSACTION_fld_Category)

   'if you want new information then get it this way
   lProgID = oCodeTableServer.GetTableEntryID("Business Level", tbnumMembershipPrograms)
   lCatID = oCodeTableServer.GetTableEntryID("Corporate", tbnumMembershipCategories)

   Set oCats = New CMemCats
   oCats.Init REApplication.SessionContext

   For Each oCat In oCats
       If (lProgID = oCodeTableServer.GetTableEntryID(oCat.Fields(MemCat_fld_ProgramID), tbnumMembershipPrograms)) And (lCatID = oCodeTableServer.GetTableEntryID(oCat.Fields(MemCat_fld_CategoryID), tbnumMembershipCategories)) Then
           lCatID = Val(oCat.Fields(MemCat_fld_MembershipCategoryID))
           Exit For
       End If
   Next oCat
   Set oCat = Nothing

   Set oCats = Nothing

   With oMember.Transactions.Add

       .Fields(MEMBERSHIPTRANSACTION_fld_Program) = "Business Level"
       .Fields(MEMBERSHIPTRANSACTION_fld_Category) = lCatID

       'Upgrade, downgrade, renewal, etc.
       'if you choose upgrade or downgrade then the category/program combination must be
       'different from the previous transaction
       .Fields(MEMBERSHIPTRANSACTION_fld_Type) = oCodeTableServer.StaticTableTranslation(staticnumMembershipType, staticentry_Renewal)

       'if renewal then set the renewal type
       'if you choose renewal_upgrade or renewal_downgrade then the category/program
       'combination must be different
       .Fields(MEMBERSHIPTRANSACTION_fld_Renewal_Type) = oCodeTableServer.StaticTableTranslation(staticnumMembershipRenewalType, staticentry_MembershipRenewalType_Same)

       .Fields(MEMBERSHIPTRANSACTION_fld_Dues) = 100
       .Fields(MEMBERSHIPTRANSACTION_fld_ActivityDate) = "8/1/2000"
       .Fields(MEMBERSHIPTRANSACTION_fld_Expires_On) = "8/31/2001"

   End With

   Set oMember = Nothing

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