Hi all,
I have a function I use to sort the recordset behind a form on designated
fields of the form (see code below). I pass the field name, and trigger this
function with the click of the field heading. However I'm using filters at
different times on the underlying form recordset, but want the functionality
of being able to sort the resulting recordset using my function.
I don't want to have to pass the filter to the fuinction if I can avoid it.
So im looking for a way to sort the recordsetclone.Ive tried the
recordset.sort property, but can't get it to work. Is there a way to do
this, is there a better approach.
Recordset --------->apply filter ------------->Sort result on various
fields.
-------------------------------------------------------
Function rstSort(sField As String)
Dim sortSql As String
Dim sOrder As String
Dim rs As Recordset
Set rs = Me.RecordsetClone
Dim sortString As String
If sortFlag Then
sortFlag = False
sOrder = ""
Else
sortFlag = True
sOrder = " DESC "
End If
rs.Sort = sField & sOrder
Set rs = Nothing
End Function
-------------------------------------------
Gerry Abbott