A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

sort button



 
 
Thread Tools Display Modes
  #1  
Old February 9th, 2010, 10:19 PM posted to microsoft.public.access.forms
John
external usenet poster
 
Posts: 2,649
Default sort button

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
  #2  
Old February 10th, 2010, 01: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
  #3  
Old February 10th, 2010, 01:36 AM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default sort button

Fred has given you some good approaches, including the double-click event of
your textboxes. The reason he suggested using this approach is that you
cannot have Command Buttons on a Datasheet View Forms, only on Single View
Forms or Continuous View Forms!

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via http://www.accessmonster.com

  #4  
Old February 11th, 2010, 09:05 PM posted to microsoft.public.access.forms
John
external usenet poster
 
Posts: 2,649
Default sort button

THANKS!!!

"fredg" wrote:

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
.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:21 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.