TDataset.Locate

I would like to make a search function on a dataset which makes a partial comparison of the ginen string (aFindDialog.FindText ). I try using the Locate function but I always get the first record matching the text whereas I want to proceed to the next matching record if there are more than one. So I always get to be shown the first matching record of the dataset and can't move on the next one. The database is Access..

My Code is:

  Result := False
  if aFindDialog.FindText <> '' then
    begin
      try
        Tadodataset(aFindDataset).Next;
        Result := Tadodataset(aFindDataset).Locate (aFindFieldName, aFindDialog.FindText, [loPartialKey, loCaseInsensitive]);
      except
        Exit;
      end;
    end;
 
Any ideas?
mc94051Asked:
Who is Participating?
 
D-MasterCommented:
0
 
mikelittlewoodCommented:
Yes locate will find the first match, but you can just re-run it to move to the next match.

1) find first match
2) move to next record (check not at end of dataset) - must move to next record or it will keep matching the current one
3) re-run match

You can keep doing this until you hit the end of the dataset
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.