I am interested in the answer to Jerry's question on November 11, 2004:
"Is it possible to code a command button (on click event) such that it will
replicate what happens when you click the sort icon in the toolbar (that >
A-->Z icon)?"
Here was RBrandt's reply:
"Me.OrderBy = Screen.PreviousControl.ControlSource
Me.OrderByOn = True "
I attached the code to the on_click event of the control in my form, and it
sorts in ASC. However, what code do I use to toggle the sort order between
ASC/DESC for the column on my form?
Thank you in advance.
Dirk Goldgar - 15 Apr 2005 22:23 GMT
> I am interested in the answer to Jerry's question on November 11,
> 2004: "Is it possible to code a command button (on click event) such
[quoted text clipped - 11 lines]
>
> Thank you in advance.
Something like this (untested):
'----- start of code -----
If Me.OrderByOn Then
If Screen.PreviousControl.ControlSource = Me.OrderBy Then
Me.OrderBy = Me.OrderBy & " DESC"
Else
Me.OrderBy = Screen.PreviousControl.ControlSource
End If
Else
Me.OrderBy = Screen.PreviousControl.ControlSource
Me.OrderByOn = True
End If
'----- end of code -----

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Alex - 15 Apr 2005 22:37 GMT
Hi Carole,
Ether use a global variable to hold the current value of the ASC/DESC
or a hidden checkbox on the form that is set with the click event of
the button
e.g.
the most reliable way I have found is
If Me.Check0.Value = 0 Then
Me.Check0.Value = 1
Else
Me.Check0.Value = 0
End If
I personally don't use any of the form filtering function instead I do
a dynamic build of the SQL recordsource for the form, with the ASC or
DESC on the end of the select statement, with a refresh after.
Hope it helps
Regards
Alex