Sort Property (Professional Edition Only)

See AlsoproSortSee                 ExampleproSortX>Low

Applies To

Dynaset object25TLT8, Snapshot objectHBYSUX.

Description

Determines the order of records in a recordset.  It is the ORDER BY clause in an SQL statement29F05E5 (without the words "ORDER BY").  Not available at design time; read/write at run time.

Syntax

dynasetobject | snapshotobject}.Sort [ = orderbystring ]

Remarks

You can use the Sort property to sort records in a Dynaset or Snapshot.  The Sort property affects only recordsets subsequently created from recordset with CreateDynaset or CreateSnapshot.

You can create a Dynaset or Snapshot, set its Sort property, and then create a new Dynaset or Snapshot.  If you create a Dynaset or Snapshot using an SQL statement, there is no need to set this property.  The Sort property of the new recordset is empty.  The Sort property overrides any sorting specified in the underlying QueryDef19G3DMW.

The default sort order is ascending.  The following examples show how you can set the sort order to ascending and descending.  The first two create identical results.

Data1.Recordset.Sort = "[Ship Country]"        ' Ascending order.
Data1.Recordset.Sort = "[Ship Country] Asc"    ' Ascending order.
Data1.Recordset.Sort = "[Ship Country] Desc"   ' Descending order.

 

The Sort property doesn't apply to TablesK31GNT. To sort on a Table index6SGX4U, use the Index property of a TableDef1T7W9BL.

The Sort property of a new Dynaset or Snapshot is blank because the records were sorted during the creation process.