?
Solved

ORDER BY in Recordset filter

Posted on 2004-03-26
11
Medium Priority
?
1,520 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

807 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