[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Filter One Recordset by Another Recordset

Posted on 2006-05-19
1
Medium Priority
?
301 Views
Last Modified: 2010-05-01
I have two ADO recordsets in Access. They have two common fields (say, ID_1 and ID_2). I want the first recordset to be filtered so that it only includes items also in the second recordset. This is not a simple filter (say, ID_1 > 3 and ID_2 > 200), but more involved. I cannot change the original SQL query string that resulted in either recordset. Now, the simple way is to loop through the first and then inner loop through the second, but that is awfully slow for large recordsets. Is there a better way?
0
Comment
Question by:GivenRandy
1 Comment
 
LVL 6

Accepted Solution

by:
junglerover77 earned 2000 total points
ID: 16723265
Basically, you can just order those 2 recordsets by id_1 and id_2, using "sort" property, then you will not need an inner loop to find out all the records exist in both recordsets. That is, if the recordcount of recordset1 is m, the recordcount if recordset2 is n, the loop will only be executed m+n times, not m*n .

For higher performance, you can use "Recordset.GetRows" method to put the recordset into an array, and then loop through the arrays instead of recordsets.

Regards,
Jungle
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

834 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