а если так: (елси уж очистка нужно при удачном завершении всех запросов)
Код:
procedure TBarcodeForm.Edit1Change(Sender: TObject);
var
Date:string;
Flag:bool;
begin
if (Edit1.Text='') and (Str='')
then
begin
BarcodeForm.ADOQuery1.Close;
BarcodeForm.ADOQuery1.SQL.Text:='SELECT * FROM works';
try
BarcodeForm.ADOQuery1.Open;
Except
Exit;
end;
Label9.Caption:= CountRec + IntToStr(BarcodeForm.Adoquery1.RecordCount);
end
else
begin
BarcodeForm.ADOQuery1.Close;
BarcodeForm.ADOQuery1.SQL.Text:='SELECT * FROM works WHERE cBarcode = :dd1_b';
BarcodeForm.ADOQuery1.ParamByName('dd1_b').Value:= Edit1.Text;
try
BarcodeForm.ADOQuery1.Open;
Except
Exit;
end;
Date := FormatDateTime('yyyy-mm-dd', Now);
Str:= ADOQuery1.FieldByName('nKey').asString;
Label9.Caption:= 'ID: ' + Str;
if (BarcodeForm.ADOQuery1.RecordCount > 0) and (Str <> '')
then
begin
BarcodeForm.ADOQuery1.Close;
BarcodeForm.ADOQuery1.SQL.Text:='UPDATE works SET dJobDone = '''+ Date +''' WHERE nKey = ' + Str;
try
BarcodeForm.ADOQuery1.ExecSQL;
Except
Exit;
end;
BarcodeForm.ADOQuery1.Close;
BarcodeForm.ADOQuery1.SQL.Text:='SELECT * FROM works WHERE nKey = ' + Str;
try
BarcodeForm.ADOQuery1.Open;
Except
Exit;
end;
Str:='';
end;
end;
Edit1.Text:='';
end;