Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











PROPERTY:  Recordset::Sort

string = recordsetobject.Sort
recordsetobject.Sort = string


The Sort property sets or returns a string value that provides the names of the fields in the Recordset that you wish sorted. Each name must be separated by a delimiter comma and the entire string must be enclosed within a pair of double quotes. If the field name contains blank spaces, you need to enclose it within a pair of square brackets.

You also have the option of specifying that the sort be in ascending or descending order for each individual field. You can declare the sort order by placing a blank space followed by either the keyword ASC, for an ascending sort, or DESC, for a descending sort, directly after the field name, but before the delimiter comma. The default is to sort in ascending order. Therefore, if you want an ascending sort, you could skip including the keyword ASC.

The CursorLocation property will need to be set to adUseClient.

When you are using a client-side cursor, the ADO Cursor Engine will automatically create a temporary index for the sort rather than physically rearranging the data. This makes the sort more efficient. You can also create your own temporary index by setting the Optimize property of the Properties Collection of the Field object to True.

If you are using a server-side cursor, some providers may not support this property.

Code (VBScript):
objRecordset.Sort = "LastName, Birthdate"
Or
objRecordset.Sort = "LastName DESC, FirstName DESC"

You can remove a sort by setting this property equal to the empty string "".

Code (VBScript):
objRecordset.Sort = ""

 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information