re-sorting recordset

shahid

New member
Local time
Today, 05:11
Joined
Feb 28, 2003
Messages
5
Hello...

I wanted to ask if someone can tell me a way to re-sort recordset without accessing the database again.

For example, On a website using ASP, a user requests specific data to be sorted by date in assending order...and page is displayed.
Now I want to place a link to sort the same recordset to show the user the same results in descending order... will it be possible to re-sort the recordset without accessing the database again ?

If possible then please pass me the query to do it in ASP page.
 
Last edited:
Access knows enough to not retrieve the data again. It just resorts the recordset that it already has.
 
Try pasting this code into your form's module. I originally found it on Google. It's attributed to Allen Browne although I can't find it on his web site http://allenbrowne.com/tips.html

It works very well on continuous forms although it appears to readdress the underlying tables (not sure why this would be a problem). I've found that it's not necessary to add command buttons to use it--just call the code from the column label's OnClick event.
Code:
Function SortForm(frm As Form, ByVal sOrderBy As String) As Boolean

    'Purpose:   Set a form's OrderBy to the string. Reverse if already set.
    'Return:    True if success.
    'Usage:     Command button above a column in a continuous form:
    '               Call SortForm(Me, "MyField")
    
    If Len(sOrderBy) > 0 Then
        ' Reverse the order if already sorted this way.
        If frm.OrderByOn And (frm.OrderBy = sOrderBy) Then
            sOrderBy = sOrderBy & " DESC"
        End If
        frm.OrderBy = sOrderBy
        frm.OrderByOn = True
        ' Succeeded.
        SortForm = True
    End If
End Function
 
Thanx for the code, it will certainly prove handy later on. Please see my updated question.
 

Users who are viewing this thread

Back
Top Bottom