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

ID: Q167928


The information in this article applies to:


SUMMARY

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

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.

  1. Open the form for which you want to change the sort order in Design view.


  2. Open the property sheet for the form, and click the Event tab.


  3. Set the OnOpen property for the form to the following [Event Procedure]:
    
          Private Sub Form_Open(Cancel As Integer)
    
            Me.OrderBy = ""
    
          End Sub 


  4. Close the module. Save and close the form.


  5. 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.


  6. Reopen the form and note that the sort order change that you made before you closed the form has not been reapplied.



REFERENCES

For more information about sorting data in forms, search the Help Index for "sorting data, forms," or ask the Microsoft Access 97 Office Assistant.


Keywords          : kbusage FmsHowto FmsProb FmrCdbeh 
Version           : 7.0 97
Platform          : WINDOWS 
Issue type        : kbinfo 

Last Reviewed: April 26, 1999