sort button

  • Thread starter Thread starter john
  • Start date Start date
J

john

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
 
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.
 
THANKS!!!

fredg said:
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
.
 
Back
Top