I am searching for a particular record by passing through the table until I found the corresponding ID

While Searching,I have displayed a progress bar to show the evolution of the search.

Also, Since usually the last records in the table are the most often used, I have used the following mechanism to search:

- Check if the ID > total Number of records / 2

if yes then

-move to last record and then continuously move previous until the search id is found

else
-move first and then move next.


my problem is when I move last and then move previous, The progress bar also move backwards as I have set the max value to Total number of records and Min Value to the Search ID


So what's the solution to make the progress bar move forward even though I am moving backwards in the table?

thanks