ADO Database Delphi

Title: Search record in TQuery
Use something like example below, but it could use some exception handling.
Call DisableControls before iterating through a large number of records in the dataset to prevent data-aware controls from updating every time the active record changes.
Disabling controls prevents flicker and increases speed because data does not need to be written to the display.
procedure TForm1.Button1Click(Sender: TObject);
var
StringToFind: string;
CurrentPos: TBookmark;
Found: Boolean;
begin
StringToFind:=Edit1.Text;
if Form1.Query1.State=dsEdit then
Form1.Query1.Post;
if StringToFind='' then
Exit;
with Form1 do
begin
CurrentPos:=Query1.GetBookmark;
Query1.DisableControls;
Found:=False;
Query1.Next;
while (not Query1.EOF) and (not Found) do
begin
if Query1.Fields[1].AsString=StringToFind then
Found:=True;
if not Found then
Query1.Next;
end;
if not Found then
begin
MessageDlg(
'No more matching members found.',
mtInformation,
[mbOK],
0);
Query1.GotoBookmark(CurrentPos);
end;
Query1.EnableControls;
Query1.FreeBookmark(CurrentPos);
end;
end;