Sorting By Different Fields On a Form
I have a form with 4 columns, and I would like to be able to sort on any column I choose.
I put a toggle above each column, and for each toggle I redefine the SQL to order by that field and save the query def. That part works .... but it will not refresh the view on the form to show me the resorted data.
If I close the form and reopen it it is sorted by the last column that I chose, so I know thats working.
If I click in a field and use that AZ icon on the access toolbar, then it sorts and refreshes on that column. But that icon won't visible neccesarily to the user.
But me.requery is not working. I am not using a cloned recordset.' How do I make the view show the new sort order?
Private Sub SetSQLBase()
SQLSort = "SELECT t_EmpCrewAssignment.CrewName, t_EmpCrewAssignment.Cr" _
& "ewID, t_EmpCrewAssignment.EmpName, t_EmpCrewAssignment.EmpI" _
& "D" & vbNewLine & "FROM t_EmpCrewAssignment" & vbNewLine
End Sub
Private Sub tglSortCrewID_Click()
UntoggleSortKeys ("tglSortCrewID")
SetSQLBase
SQLSort = SQLSort & "ORDER BY t_EmpCrewAssignment.CrewID;" & vbNewLine
CurrentDb.QueryDefs("q_EmpCrewAssignment").SQL = SQLSort
Me.Requery
End Sub
|