Sort A Field In Descending Order
acCmdSortDescending
The following code sorts a field in descending order. Create a button called cmdSortDesc and put the code behind it.
'***************** Code Start *******************
' Code by Terry Wickenden
Sub cmdSortDesc_Click()
On Error Goto ErrHandler
Screen.PreviousControl.SetFocus
DoCmd.RunCommand acCmdSortDescending
Exit Sub
ErrHandler:
Select Case Err
Case 2046
'Command not available
MsgBox "Sorting is not available at this time.", vbCritical, "Not Available"
Case Else
MsgBox Err.Number & ":-" & vbCrLf & Err.Description
End Select
End Sub
'****************** Code End ********************