[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1209
  • Last Modified:

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?
0
mc94051
Asked:
mc94051
1 Solution
 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now