Yes, you can write a for next loop w/ locate from 0 to the number and when 
there's an exact match, it will move there... it worked for me using integers, 
might be tougher using floating point.

Dave

--- On Sat, 3/7/09, pietro <pietro.bo...@bluewin.ch> wrote:
From: pietro <pietro.bo...@bluewin.ch>
Subject: [advanced_delphi] ADOQuery, how to find nearest ?
To: advanced_delphi@yahoogroups.com
Date: Saturday, March 7, 2009, 3:03 PM

Hello,

First of all, many thanks for your previous (and precious) help !

Need to solve this problem:

I have a DBGrid connected to ADOQuery  (Delphi-7).  One field contain 
number between 0.000 and 30000.000
User can input a number in this range, than the cursor should move to 
the exact or nearest value (record).
It works perfectly with LOCATE, but only when input data are exactly the 
same on the record value.

Is there any simple solution to move cursor to the nearest value ?


In the mean time, I implemented a simple routine with  a dataset scan ( 
while not eof) and storing in a bookmark the exact record number or  
last previous / first after record number
with a simple if a >= b then  set the bookmark, exit the scan routine, 
then move the dbgrid cursor to the bookmark.
It's works, but it's not a very beautiful implementation..............

Any idea ?

Pietro



------------------------------------

Yahoo! Groups Links






      

Reply via email to