aesarvan:
If your subform is in continuous format, you can use this. It's from a paper I use in class:
Access Code Sample
Setting sort order command buttons on Continuous Display forms.
For each field to be sorted, add a command button to the form header band.
Provide an appropriate caption
Provide an appropriate name
In the On_Click event for each button add this code:
strSortField = “FieldName”
Call SortOrder
In the General Declarations section of the form’s module add this:
Dim strSortfield As String
Add a sub procedure (private) to the form’s module named SortOrder; enter this code:
Private Sub SortOrder()
Dim bolOrder As Boolean
Dim strOrder As String
Screen.ActiveForm.AllowAdditions = False
DoCmd.GoToControl strSortField
strOrder = InputBox("Enter A for Ascending; D for Descending", "Sort Order", "A"
If strOrder = "A" Then
bolOrder = True
ElseIf strOrder = "d" Then
bolOrder = False
Else
MsgBox "Invalid Selection", vbOKOnly + vbCritical, "Sort Order"
Exit Sub
End If
If bolOrder Then
DoCmd.RunCommand acCmdSortAscending
Else
DoCmd.RunCommand acCmdSortDescending
End If
End Sub
This is based on using Command Buttons as the headers, but, of course, you can use this with the On Click event of a label as well.
HTH
Larry De Laruelle
ldelaruelle@familychildrenscenter.org