C
cinnie
hi to all
I have been making use of a great Function (sorry, I don't remember the
author) to sort the records in a Subform using a cmd Button on the Main Form.
I use 4 of these buttons placed above columns I want to sort in the Subform.
The button's On Click event in the property window is set to:
=SortForm(Forms.MasterFormName.SubFormName.Form,"PutRecordSourceHere")
The function is:
Function SortForm(frm As Form, ByVal strOrderBy 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(strOrderBy) > 0 Then
' Reverse the order if already sorted this way.
If frm.OrderByOn And (frm.OrderBy = strOrderBy) Then
strOrderBy = strOrderBy & " DESC"
End If
frm.OrderBy = strOrderBy
frm.OrderByOn = True
SortForm = True
End If
End Function
Here is my question. Can this function be altered so that more than one
sort criteria could be used? Perhaps the results of one sort could be
'remembered' when a second sort is clicked. It would be great, for example,
to click LastName, then City to alphabetize sales people by city.
Any clues? This type of programming is still beyond my reach.
I have been making use of a great Function (sorry, I don't remember the
author) to sort the records in a Subform using a cmd Button on the Main Form.
I use 4 of these buttons placed above columns I want to sort in the Subform.
The button's On Click event in the property window is set to:
=SortForm(Forms.MasterFormName.SubFormName.Form,"PutRecordSourceHere")
The function is:
Function SortForm(frm As Form, ByVal strOrderBy 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(strOrderBy) > 0 Then
' Reverse the order if already sorted this way.
If frm.OrderByOn And (frm.OrderBy = strOrderBy) Then
strOrderBy = strOrderBy & " DESC"
End If
frm.OrderBy = strOrderBy
frm.OrderByOn = True
SortForm = True
End If
End Function
Here is my question. Can this function be altered so that more than one
sort criteria could be used? Perhaps the results of one sort could be
'remembered' when a second sort is clicked. It would be great, for example,
to click LastName, then City to alphabetize sales people by city.
Any clues? This type of programming is still beyond my reach.