Sort Property (Professional Edition Only)
See Also Example
Applies To
Dynaset object, Snapshot object
Description
Determines the order of records in a recordset. It is the ORDER BY clause in an SQL statement (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 QueryDef .
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 Tables
The Sort property of a new Dynaset or Snapshot is blank because the records were sorted during the creation process.