Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Sorting via vba code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
peruvian99 - 13 Jul 2007 18:42 GMT
I have this form which I want to be able sort by clicking on a command button.

For instance if the button is above the "stocks" field 9textbox) - clicking
on the command button right above it would sort it descending. --- clicking
on the command button above the field "Profits" -- it would be sort it
descending by the amount.

I can currently do this by clicking the sort button in the toolbar, but I
want to do this via vba cide.

JPierre
Carl Rapson - 13 Jul 2007 19:46 GMT
>I have this form which I want to be able sort by clicking on a command
>button.
[quoted text clipped - 10 lines]
>
> JPierre

What you would need to do is, in the button's Click event modify the form's
OrderBy property to include the proper sorting. Be sure to also set
OrderByOn to True when you do so. Look in Access help for OrderBy and
OrderByOn.

You could also accomplish this by changing the form's RecordSource property
directly, if you wished.

Carl Rapson
Marshall Barton - 13 Jul 2007 20:06 GMT
>I have this form which I want to be able sort by clicking on a command button.
>
>For instance if the button is above the "stocks" field 9textbox) - clicking
>on the command button right above it would sort it descending. --- clicking
>on the command button above the field "Profits" -- it would be sort it
>descending by the amount.

Use code in each button's Click event procedure:

Me.OrderBy = "[Stocks] DESC"
Me.OrderByOn = True

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.