Var I,J:Integer;
begin
Table1.DisableControls;
Table1.Locate('LastName',Edit2.Text,[]);
J:=TDrawGrid(DBGrid1).rowcount;
For I:=1 To J do
begin
if Table1.Eof then Break;
Table1.Next;
end;
if Table1.Eof
then For J:=2 To I-1 do Table1.Prior
else For J:=1 To I-1 do Table1.Prior;
Table1.EnableControls;
end;