Full Version: Rounding or finding closest matching number
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
zekebar
I have a table with a list of results like this
A B
1.1 60
1.2 75
1.3 90
1.4 99

I am trying to take the number of a text box and to a dlookup of coumn B that is the closest match and give me the result of column A

Example:
the value I have is 82 I need it to find the closest value in colum B (75) and Return Column A (1.2)

Anyone might have a suggestion.


Thank You
Zeke Barlow
frown.gif
Jerry Dennison
To find the nearest number you need only find the Min of the absolute value of the difference between the two numbers.

Min(ABS([B] - [ComparisonFieldName]))
zekebar
I am not quite understanding here.

Here is my Control Source
=DLookUp("[GE]","GEConversion","[VO]= " & Min(Abs([GEConversion]![VO]-[VC])))

GE = The number I want
VO = The Column In the Table That I Comparing
VC = The name of the text box on the form that has the value I am trying to find the nearest value in the VO
Column
GEConversion = The name of the table I am looking in.

Example:
the value I have is [VC] "82" I need it to find the closest value in colum VO (75) and Return Column GE (1.2)

Do you have any suggestions on what I am doing wrong here.
It returns "Error"

Thank You
Zeke Barlow
frown.gif
Jerry Dennison
You will need to use a query to return the values, not a domain aggregate function.
zekebar
I am a little lost here.
Could you help me out here
Here is a copy of the database.

Zeke Barlow
frown.gif
Jerry Dennison
Since I don't have a clue which tables you're trying to compare it will be impossible for me to offere anything. You need to re-examine your table structure. You have repeating groups and repeating entities. These should be resolved before moving forward. I strongly suspect that once you get your structure correct you will answer your own question on how to cross-reference related values.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.