Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

take the value closest to one

Status
Not open for further replies.

ersatz

Programmer
Oct 29, 2002
114
US
Hi,
I have 5 ms access columns with data like that:
0.905
0.933
0.962
0.973
0.990
1.007
1.018
How can I take the value closest to one?

Can anybody help me, please?
Thanks in advance,
ersatz
 
I'm not familiar with Access, so don't know how to get at the column values. But your code would probably include something like the following few lines:

loop through all values....

if abs(CurrentVal-1)<abs(ClosestVal-1) then
ClosestVal=CurrentVal
{if necessary, set pointer to current record here}
end if

.... end loop

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top