Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching table through filter property 2

Status
Not open for further replies.

math

Programmer
Mar 21, 2001
56
BE
Hi,

I need to be able to search a table for searchstrings...
The table is a Adressbook and what I want to do is search on names with the Filter property...

Table1.Filter := 'Name = ' + QuotedStr(EditSearch.Text);

This works, but then you have to search for the full name, correctly spelled or it won't work... What I want is to be able to search for parts of the name... For example: I search for "ters" then the Adress of "Peeters Jack" should be with the results... using CompareText doesn't seem to work?

Can anyone help me?
Thanx in advance,
math
 
Write an OnFilterRecord event handler for Table1.

For your example, the code will look something:

procedure TForm1.Table1FilterRecord(DataSet: TDataSet;
var Accept: Boolean);
begin
Accept := Pos ( EditSearch.Text, Table1Name.AsString ) > 0;
end;

Remember to set Table1.Filtered to true to activate the filter. Do not put anything in the Filter property.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top