Microsoft KB Archive/167928

= ACC: How Microsoft Access Saves Sort Order of Form Depends on Version =

Article ID: 167928

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q167928



Moderate: Requires basic macro, coding, and interoperability skills.



SUMMARY
In Microsoft Access 7.0 and 97, the sort order that you apply to a field in a form is saved when you save the form or datasheet, and is reapplied automatically when you reopen the form or base a new form or report on that form. This behavior is different from Microsoft Access 2.0. In Microsoft 2.0, the specified sort order is not reapplied when you reopen the form.



MORE INFORMATION
In Microsoft Access 7.0 and 97, the OrderBy property of the form is updated with the control name when you save the form. If you want to change this functionality, you must change the OrderBy property in the Open event of the form. The following example demonstrates how to do so.

NOTE: The OrderBy property setting for the form will not be saved if you open the form in Design view and then switch to Form view to change the settings. You must open the form in Form view and then make the necessary changes.

 Open the form for which you want to change the sort order in Design view. Open the property sheet for the form, and click the Event tab.  Set the OnOpen property for the form to the following [Event Procedure]:

Private Sub Form_Open(Cancel As Integer)

Me.OrderBy = ""

End Sub  Close the module. Save and close the form. Reopen the form and change the sort order for one of your fields by clicking the Ascending (A-Z) or Descending (Z-A) button on the toolbar. Close the form. Reopen the form and note that the sort order change that you made before you closed the form has not been reapplied.</li></ol>

<div class="references_section">