Click here to go to the Office Update Home page   All Products  |   Support  |   Search  |   microsoft.com Guide  
Featured on Office UpdateMicrosoft
   Home   |    Auto Update   |    What's New   |    Search Office Update   |    eServices   |    Office Update Worldwide   |    Site Help   |
 
Table of Contents

Sorting Records in an Access 2000 Project

About Sorting Records Before They're Retrieved from the Database

About Sorting Records After They're Retrieved from the Database

About Working Around Table and View Sort Limitations

Deciding When to Sort

How to Sort Records Before They're Retrieved from the Database

How to Sort Records After They're Retrieved from the Database

How to Work Around Table and View Sort Limitations

Summary of Sort Operations

Sorting Records in an Access Project: Additional Resources

  

How to Sort Records Before They're Retrieved from the Database Click here to email this to a friend.

There are two ways you can sort records before they are retrieved from the database: you can add an ORDER BY clause to either a stored procedure or an SQL statement.

Create a stored procedure with an ORDER BY clause
  1. In the Database window, click Stored Procedures under Objects, and then click New on the Database window toolbar.
    A new stored procedure is created using skeleton SQL statements.

    Stored procedure window with skeleton SQL statements

  2. If desired, replace StoredProcedure1 in the first line with the unique name of the procedure. For example, you might use "MyProcedure" as the name:
    Create Procedure MyProcedure
  3. Write the remaining procedure text in SQL and add an ORDER BY clause.
    Tip  If you don't know SQL syntax, you can create a view in the Query Designer and then convert the view to a stored procedure, as described in How to Work Around Table and View Sort Limitations.

Create an SQL statement with an ORDER BY clause
  1. In the Database window, click Forms or Reports under Objects, select a form or report, and then click Design on the Database window toolbar.
  2. Click the Properties button, click the Data tab, and then click the Build button to the right of the RecordSource property box.
  3. Add the columns or expressions that you want to sort by to the Grid pane.
  4. In the Output column of the grid, clear the check boxes for any columns or expressions that you don't want to be part of the query results.
  5. In the Sort Type grid column for each row containing a column or expression you want to sort by, click Ascending or Descending.
  6. If you are sorting by multiple columns or expressions, specify the sort order in the Sort Order column of the grid.
  7. On the View menu, point to Show Panes, and then click SQL. Note that Access creates the ORDER BY clause for you based on the information you enter in the Grid pane.

    SQL statement window showing a complex sort

    
 
é

© 2000 Microsoft Corporation.
All rights reserved. Terms of use.  Disclaimer.