Public Sub Test() Dim pTable As ITable Set pTable = FindTableInMap("Downstream_Polylines") Dim pTableSort As ITableSort Set pTableSort = New esriGeoDatabase.TableSort With pTableSort Set .Table = pTable Set .QueryFilter = Nothing .Fields = "OBJECTID" .Ascending("OBJECTID") = True ' TRUE is ascending, if set to FALSE then descending .Sort Nothing End With Dim pCursor As ICursor Set pCursor = pTableSort.Rows Dim pRow As IRow Set pRow = pCursor.NextRow Do While Not pRow Is Nothing Debug.Print pRow.Value(0) Set pRow = pCursor.NextRow Loop End Sub
Demetris,
See sample VBA code below on how to get a descending sort order.
Duncan
Public Sub Test() Dim pTable As ITable Set pTable = FindTableInMap("Downstream_Polylines") Dim pTableSort As ITableSort Set pTableSort = New esriGeoDatabase.TableSort With pTableSort Set .Table = pTable Set .QueryFilter = Nothing .Fields = "OBJECTID" .Ascending("OBJECTID") = True ' TRUE is ascending, if set to FALSE then descending .Sort Nothing End With Dim pCursor As ICursor Set pCursor = pTableSort.Rows Dim pRow As IRow Set pRow = pCursor.NextRow Do While Not pRow Is Nothing Debug.Print pRow.Value(0) Set pRow = pCursor.NextRow Loop End Sub