Thread: sort button
View Single Post
  #2  
Old February 10th, 2010, 12:19 AM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default sort button

On Tue, 9 Feb 2010 13:19:02 -0800, john wrote:

I have a datasheet form that I would like to click on the column header and
then click on a button (a to z) or (z to a) that will sort the data in either
ascending or descending order. This is simple if I leave the toolbar enabled
but I would like to do this with a command button. I'm not a programmer and
have little understanding of module etc. Any advice


Simply Right-click on the column header and select Sort Ascending or
Sort Descending from the shortcut menu.

Or if you must create your own code you can't use the column header.

You can code "each" control's double-click event:

If Me.OrderBy = "[ThisFieldName] Desc" then
Me.OrderBy = "[ThisFieldName]"
Else
Me.OrderBy = "[ThisFieldName] Desc"
End If
Me.OrderByOn = True

Change ThisFieldName to whatever the actual name of the field is. Make
sure it's within brackets and quotes as above.

Click on the actual control to re-sort when wanted, not on the column
header. Click a second time to re-sort again.


--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail