![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a subform with various columns. At the top of each column there is a button that the user can click to sort the form using the column field. Clicking the button calls this function Public Function SortForm(frm As Form, ByVal sOrderBy As String) On Error GoTo Err_SortForm 'Purpose: Set a form's OrderBy to the string. Reverse if already set. '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 End If Now when the user exits the form I make a note of which button was clicked last. Question - how do I make sure the form is sorted by that column when it next opens? Write the sort order variable to a table. Use the form's on load |
#3
| |||
| |||
|
|
"buckskin" <bucko (AT) mailinator (DOT) com> wrote in news:9l672aF3gqU1 (AT) mid (DOT) individual.net: I have a subform with various columns. At the top of each column there is a button that the user can click to sort the form using the column field. Clicking the button calls this function Public Function SortForm(frm As Form, ByVal sOrderBy As String) On Error GoTo Err_SortForm 'Purpose: Set a form's OrderBy to the string. Reverse if already set. '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 End If Now when the user exits the form I make a note of which button was clicked last. Question - how do I make sure the form is sorted by that column when it next opens? Write the sort order variable to a table. Use the form's on load event to query that table and load your variable from the table. |
![]() |
| Thread Tools | |
| Display Modes | |
| |