Public Sub SeatingSort()
    Dim oSection As cEventSection
    Dim oTable As cSectionTable
    Dim oSeat As cTableSeat
    Dim oSeats As cEventSeating2
    Dim oSort As IBBSortedCollection
    Dim ReService As REservices
    Dim sSortKey As String
    Set oSeats = New cEventSeating2
    oSeats.Init REApplication.SessionContext
    oSeats.LoadByEventID 8
    Set ReService = New REservices
    ReService.Init REApplication.SessionContext
    Set oSort = ReService.CreateServiceObject(bbsoSortedCollection)
    Debug.Print "Before Sort"
    For Each oSection In oSeats.Sections
        For Each oTable In oSection.Tables
            For Each oSeat In oTable.Seats
                Debug.Print oSeat.Fields(EVENTTABLESEAT_fld_SectionID) & " " & oSeat.Fields(EVENTTABLESEAT_fld_TableID) & " " & oSeat.Fields(EVENTTABLESEAT_fld_SeatNumber)
                sSortKey = oSeat.Fields(EVENTTABLESEAT_fld_SectionID) & " " & oSeat.Fields(EVENTTABLESEAT_fld_TableID) & " " & oSeat.Fields(EVENTTABLESEAT_fld_SeatNumber)
                oSort.Add oSeat, oSeat.Fields(EVENTTABLESEAT_fld_ID), sSortKey
            Next oSeat
        Next oTable
    Next oSection
    'Resorts the collection using the sort key property that was defined
    'when adding to the collection
    Debug.Print "________________"
    Debug.Print "After Sort"
    'See the new sorted collection
    For Each oSeat In oSort
        Debug.Print oSeat.Fields(EventSeats_fld_Section) & " " & oSeat.Fields(EventSeats_fld_TableRow) & " " & oSeat.Fields(EventSeats_fld_Seat)
    Next oSeat
    'Clean up
    Set ReService = Nothing
    Set oSeats = Nothing
    Set oSection = Nothing
    Set oTable = Nothing
    Set oSeat = 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.