sort vs orderby

  • Thread starter Manuel C via AccessMonster.com
  • Start date
M

Manuel C via AccessMonster.com

Hello everyone

I have used both OrderBy and acCmdSort to sort both ascending and descending
on various fields in a form. I personally prefer using OrderBy because i
don't have to move the focus to the desired field before sorting. But i was
wondering, is there any difference or any benefit of using one over the other?


Thanks

Manny
 
A

Allen Browne

If you always want the form sorted in a particular way, the most efficient
solution is to use a query as the form's RecordSource, and specify the
sorting there.

The OrderBy is simplest way to alter the sort order on the fly; you can do
that regardless of what field has focus, specify a combination of fields,
easily handle subforms, and even set the OrderBy of a form that does not
have focus.

The RunCommand is the least useful approach, as it does depend on what has
focus.

Unfortunately, these is a bug if you set the Filter/OrderBy for both the
main form and the subform both. Details in:
Incorrect filtering
at:
http://allenbrowne.com/bug-02.html
This problem applies no matter how you set the filtering or sorting.
 
M

Manuel C via AccessMonster.com

Allen:

Thanks for the info. I was not aware of these bugs, i will try to avoid them
as i continue to learn about Access.

Manny


Allen said:
If you always want the form sorted in a particular way, the most efficient
solution is to use a query as the form's RecordSource, and specify the
sorting there.

The OrderBy is simplest way to alter the sort order on the fly; you can do
that regardless of what field has focus, specify a combination of fields,
easily handle subforms, and even set the OrderBy of a form that does not
have focus.

The RunCommand is the least useful approach, as it does depend on what has
focus.

Unfortunately, these is a bug if you set the Filter/OrderBy for both the
main form and the subform both. Details in:
Incorrect filtering
at:
http://allenbrowne.com/bug-02.html
This problem applies no matter how you set the filtering or sorting.
I have used both OrderBy and acCmdSort to sort both ascending and
descending
[quoted text clipped - 3 lines]
wondering, is there any difference or any benefit of using one over the
other?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top