Nested Loops

joycek

New member
Local time
Today, 14:49
Joined
Aug 14, 2006
Messages
7
Hello,

I'm trying to write a relatively simple function. What I want it to do is count pairs of records within "range" of one another - to determine whether a record is in range or not is trivial. So I want to compare the first record to every other record in the table, second record to every other record (excluding the first). I know how to set this up as a nested for loop in other languages but my knowledge of vba is virtually nil.

If anyone could help me out I would greatly appreciate this. Thanks.
 
What is the datatype of this "range". You maybe able to just use a query/subquery combination to do it.
 
Hi!

To determine whether a record is in range of another or not is based on several fields ie: They have to be at the same location within a certain window of time and various other factors. I've already tried the Query/Subquery route and it seems to lead to a dead-end. I'd prefer to do it programmatically if at all possible.

, regards
 
Well here is the deal, full table scans will give you really crappy performance.
I would use a do loop to read through your table, and create a select query dynamically with your "range" and then handle that result set. This is still a performance masher, but not as bad as reading each record in VBA once for each record (does that make sense?)
 
That sounds like a great idea! Thanks for your help!
 

Users who are viewing this thread

Back
Top Bottom