Solved

ORDER BY in Recordset filter

Posted on 2004-03-26
11
1,505 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

18 Experts available now in Live!

Get 1:1 Help Now