You can try this: if the first argument (col) is "LastName", then also sort by firstname
Code:
Private Function basOrderby(col As String, xorder As String) As Integer
Dim strSQL As String
strSQL = "SELECT DISTINCTROW PersonID, LastName, FirstName, MiddleName, DeathDate "
strSQL = strSQL & "FROM AllDeathRecords "
If col = "LastName" Then
strSQL = strSQL & "ORDER BY " & col & " " & xorder & ", FirstName"
Else
strSQL = strSQL & "ORDER BY " & col & " " & xorder
End If
Me!lstSearch.RowSource = strSQL
End Function
This version of the code adds an optional argument "col2":
Code:
Private Function basOrderby(col As String, xorder As String, Optional col2 As String) As Integer
Dim strSQL As String
strSQL = "SELECT DISTINCTROW PersonID, LastName, FirstName, MiddleName, DeathDate "
strSQL = strSQL & "FROM AllDeathRecords "
If IsMissing(col2) Then
strSQL = strSQL & "ORDER BY " & col & " " & xorder
Else
strSQL = strSQL & "ORDER BY " & col & " " & xorder & ", " & col2
End If
Me!lstSearch.RowSource = strSQL
End Function
"col2" will always sort ascending
The 2nd example is more flexible. You would call it
basOrderby("LastName", "Desc", "FirstName")
or
basOrderby("DeathDate", "Desc")
These are untested, but should work...