Exemplu:
in campul "Identif", pot avea urmatoarele inregistrari:
A2S3 34FR445 (TR), 56DR1002 (H)
sau numai
A2 35HT677 (TR)
Codul pe care l-am realizat, filtreaza, dar nu imi ia in calcul si cel de-al doailea tip de inregistrare.
Ma intereseaza sa tina cont numai de PRIMA APARITIE a stringului dintre primele paranteze
procedure TForm1.DenTara(Sender: TObject);
begin
Query2.Active := True;
Query2.First;
varB:='';
While Not (Query2.EOF) do
begin
if (DBLCBox1.Text = Query2.FieldByname('DENUMIRE').AsVariant) then
begin
varB:= '('+Trim(Query2['DENP'])+')';
Label8.Caption := 'Abreviere '+ varB;
if D1.Date > D2.Date then
begin
ShowMessage('Data de inceput este mai mare decat data finala ...!');
exit;
end;
Query1.Close;
with Query1 do
begin
SQL.Clear;
SQL.Add('SELECT * FROM Table1.dbf');
SQL.Add('WHERE Identif LIKE ''%'+varB+'%_''');
SQL.Add('AND Dat_cint between :Data1 and :Data2');
SQL.Add('AND Eroare=" "');
ParamByName('Data1').AsDate:=Self.D1.Date;
ParamByName('Data2').AsDate:=Self.D2.Date;
Open;
end;
If Query1.RecordCount > 1 then
Label3.Caption:='In perioada '+DateToStr(d1.Date)+' - '+DateToStr(d2.Date)+' aveti un numar de '+ IntToStr(Query1.RecordCount)+ ' inregistrari'
else if Query1.RecordCount = 1 then
Label3.Caption:='In perioada '+DateToStr(d1.Date)+' - '+DateToStr(d2.Date)+' aveti '+ IntToStr(Query1.RecordCount)+ ' inregistrare'
else if Query1.RecordCount = 0 then
Label3.Caption:='In perioada '+DateToStr(d1.Date)+' - '+DateToStr(d2.Date)+' nu aveti inregistrari';
Exit;
end
else
Query2.Next;
end;
end;
Aceasta postare a fost editata de nadu: 07 July 2007 - 08:54 AM
Contact
Facebook
Twitter
RSS














