I'm trying to simplify a very complex problem, so it is possible that I might leave out a few details, but I will try not to.
Basically, I have a table which has a number field (among others) that have a variable distance between the numbers. For example, the table might hold the following numbers:
- 98.891
-
100.664
-
101.527
-
102.344
-
103.135
I need to be able to type a number in a form and find the record whose number is closest to the one that I entered. For example if I enter 101.4, then it will find the third record. If I enter 100.7, it would find the second record. I have come up with a very complicated process of using two recordsets and looping through the table with the first recordset starting on the first record and the second recordset starting on the second and then do a .MoveNext on each at the same time and then testing if the value in recordset 1 is less than or equal to the value and recordset 2 is greater than or equal to the value so that I could find the two records that the value is between and then subtract the lower amount from the given amount and the given amount from the higher amount and compare the two results to see which one is closer. Again, this seems very complicated. I just hope someone can either come up with a better idea or just confirm that my idea is the only way to go.
Hopefully I made my question clear.