Open a form sorted

DOF2001

Active Member
Joined
Jan 28, 2005
Messages
310
Hello,

how can i open a form, using access 2003, sorted by 3 or more fields?


thank sin advance for all your help!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You can set the Order By as it opens. For example, if we have fields of Country, LastName, and FirstName and we want to use the code to open the form and set the order in the order I listed them, it would be:

Code:
DoCmd.OpenForm "FormNameHere", acNormal
Forms!FormNameHere.OrderBy = "Country,LastName,FirstName"
Forms!FormNameHere.OrderByOn = True
 
Upvote 0
Another way is if your Form is based on a query, do all the sorting in the query. It should translate over to the Form.
 
Upvote 0
Another way is if your Form is based on a query, do all the sorting in the query. It should translate over to the Form.

Good point Joe. That is the best way if you can do that. If you aren't needing to dynamically change it then just set it in the saved query, or SQL Statement, that you use as a recordsource in place of a table. :)
 
Upvote 0
Thank you the the super fast response,

I used Blobarson solution, just what i needed. just one think how can i sorted using one field in descending and other is ascending order.

Thanks again
 
Upvote 0
Figure it out Thanks!

DoCmd.OpenForm "FormNameHere", acNormal
Forms!FormNameHere.OrderBy = "Country DESC,LastName,FirstName"
Forms!FormNameHere.OrderByOn = True
 
Upvote 0
--Bob;
What does the "OrderByOn" command set to True do?

Alan

Alan:

Anytime you set a filter you have to turn it on using FilterOn = True and the same goes for sorting. You need to apply the filter you've set by using OrderByOn = True.
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,519
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top