Filtrowanie bazy danych - właściwość FILTER

0

Przeszukałem google dokładnie, wszak powiedziano: "guglajcie a znajdziecie" ale nie znalazłem rozwiązania.

Czy własność filter komponentu TTable umożliwia wyświetlenie rekordów które zawierają w polu np nazwisko literki 'wa' w dowolnym miejscu?

Np żeby znalazł rekord w którego polu nazwisko jest wartość Nowak (szukamy literki wa)

Z góry dzięki za pomoc

0

A czyż nie powiedziano helpujcie aż znajdziecie ?

procedure TForm1.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean);
begin
Accept := Pos('wa', DataSet.FieldByName('FIELD').AsString) > 0;
end;

albo

Filter := ' FIELD LIKE '%wa%'

0

3 sekundy szukania na google...

Table1.Filtered:=False;
Table1.Filter:='Name='van der';
Table1.Filtered:=True;

A few tips.
If a query is run on the table it will only execute on the fields that is visible after the filter is executed. This if the filter is

Table1.Filter:='Name='van der'; 

then the query will only return results were the name were equal to 'van der'

You can insert a asteriks into a search

Table1.Filter:='Name='van der*'; 

which will find anything that starts simmarly

Remember to always make the filterd property true and when you are searching case independant set the filteroptions->caseinsensitive to true

You can do combination filters

Table1.Filter:='Name='Jan*' and Surname='%wa%';

or you can even do nested combinations

Table1.Filter:='(Name='van der*' and Surname='k*')or number=10';

1 użytkowników online, w tym zalogowanych: 0, gości: 1