Solved

ORDER BY in Recordset filter

Posted on 2004-03-26
11
1,501 Views
Last Modified: 2012-08-14
Hi,

Does ORDER BY work in recordset filter??  I tried it, but it did not???  Thanks
0
Comment
Question by:mcrmg
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 10686957
Hi mcrmg,

No but it should preserve any existing orderby clause used to generate the base recordset.

Tim Cottee
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 

Author Comment

by:mcrmg
ID: 10687020
So, if I want to change order, I can not use filter??
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 10687144
filter will just Filter by field you may wanna change the recordsource and then requery
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 10687146
mcrmg,

No, all this does is a apply a filter as the name suggests. If you want to change the order you need to requery with a different order by clause or display the data in a control that supports sorting.

Tim.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10687208
It is generally best not to use the filter. Here is why:

If you want certain records in a certain order, using a specific SQL select will bring only those necessary records into the recordset. If, however, you use the filter, you bring over all records to the recordset and then filter out the unnecessary records. This is not an efficient way to do things.

FtB
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Accepted Solution

by:
AlfaNoMore earned 80 total points
ID: 10687239
objRS.Filter = "X='Y'"
objRS.Sort "X Desc, Z Asc"
0
 

Author Comment

by:mcrmg
ID: 10688022
@fritz_the_blank,

What if it always return, say, 100 records, I just want to see that in different order??
0
 

Author Comment

by:mcrmg
ID: 10688024
@fritz_the_blank,

What if it always return, say, 100 records, I just want to see that in different order??
0
 
LVL 46

Assisted Solution

by:fritz_the_blank
fritz_the_blank earned 20 total points
ID: 10688115
If you are just trying to work with a small subset, then that would be fine. Just make sure that you have SQL do as much of the work as you can rather than using the recordset object to do so. The former is much more efficient than the latter.

http://www.w3schools.com/ado/prop_rs_filter.asp

Fritz the Blank
0
 
LVL 4

Assisted Solution

by:mistyrae
mistyrae earned 20 total points
ID: 10691014
It is inefficient to do it this way, but you can use the .Sort property of the recordset to complete the operation...

Something like oRs.Sort = "MyField DESC"

You can use the Filter on your recordset and then sort it if you want to.

This page http://www.devguru.com/Technologies/ado/quickref/recordset_sort.html explains the options that are available with this method.
- misty
0
 
LVL 4

Expert Comment

by:mistyrae
ID: 10691019
pardon me, AlfaNoMore completely had it covered ;)
(I just like to type)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now