Sure. In the Open event of the report set the OrderBy property. Here's an
example from one of my own apps. "frmSortClass" is the form the user uses to
specify preferences, 'lstSort' is the list box from which they choose which
field(s) to sort by, and 'chkDescending' is a check box that indicates
whether the order should be ascending or descending. "strOrderBySource" is a
string variable I use to record the selection chosen by the user, while
"strOrderByDest" is the variable I use to build-up the string that will
eventually be assigned to the OrderBy property. "lblSubTitle" is a label on
the report that describes the sort order in use.
If CurrentProject.AllForms("frmSortClass").IsLoaded Then
strOrderBySource = Forms!frmSortClass!lstSort
Select Case strOrderBySource
Case "Name (Last, First)"
If (Forms!frmSortClass!chkDescending) Then
strOrderByDest = "LastName DESC, FirstName DESC, MiddleName
DESC"
Me!lblSubTitle.Caption = "By Family Name then Given Name,
descending"
Else
strOrderByDest = "LastName, FirstName, MiddleName"
Me!lblSubTitle.Caption = "By Family Name then Given Name"
End If
Case "Name (First, Last)"
If (Forms!frmSortClass!chkDescending) Then
strOrderByDest = "FirstName DESC, MiddleName DESC, LastName
DESC"
Me!lblSubTitle.Caption = "By Given Name, then Family Name,
descending"
Else
strOrderByDest = "FirstName, MiddleName, LastName"
Me!lblSubTitle.Caption = "By Given Name then Family Name"
End If
'other Case tests edited for brevity ...
End Select
Else
strOrderByDest = "LastName, FirstName, MiddleName"
Me!lblSubTitle.Caption = "By Family Name then Given Name"
End If
Me.OrderBy = strOrderByDest
Me.OrderByOn = True