Name
Recordset.Sort Property — (Versions 2.0, 2.1, 2.5, 2.6)
Synopsis
recordset.Sort = sortstring
The Sort property sorts a recordset on one or more field names.
Datatype
String
Description
The Sort property can be set to sort a recordset based upon one or more fields in either ascending or descending order. The Sort property accepts a String value identical to a sort clause of a SQL statement. Fields are separated by commas with either the ASC or DESC keywords following each field name. If the ASC or DESC keyword is absent, ASC is inferred.
Setting the Sort property to an empty String value (“”) removes the sort from the recordset and returns the order to the default.
For instance, the following value for the Sort property, “Company ASC, Contact DESC,” would sort the recordset by the company in ascending order and then by the contact in descending order.
The Sort property does not rearrange data within the recordset;
instead, it creates a temporary index for each field that does not
already have an index if the CursorLocation property is set to
adUseClient.
Note
Not all providers support the Sort property.
See Also
Recordset.CursorLocation Property
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access