• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

Search a memo using onfilterrecord

Hi,

I am using DBISAM as a BDE replacement and need to be able to search for text within a memo. I have been told that using onfilterrecord works, but my attempts to implement it have failed so far.

How to you do this?

Onfilterevent...

Accept:???

Thanks

John
0
JohnE
Asked:
JohnE
  • 4
  • 2
  • 2
  • +2
1 Solution
 
rwilson032697Commented:
You should be able to do this:

procedure TForm1.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean);

begin
  Accept := Pos('The string to search for', DataSet['TheMemoField']) > 0;
end;

Cheers,

Raymond.
0
 
kretzschmarCommented:
i guess that is not possible :-(
0
 
simonetCommented:
What about using the LIKE keyword:

SELECT * FROM TABLE1 WHERE FIELDX LIKE '%partial string%'

(I just can't remember if it is '%' or '*' for the LIKE comparision).

Yours,

Alex
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
kretzschmarCommented:
alex, i guess this will also not work for blobs
0
 
intheCommented:
Var
SearchCode: String;
 
procedure TForm1.Table1FilterRecord(DataSet: TDataSet;var Accept: Boolean);
  begin
Accept := (AnsiStrLIComp(PChar(Table1MemoField.AsString),         PChar(SearchCode), Length(SearchCode)) = 0);
  end;


ps alex your correct already its percent (though im not sure if it is
 '%searchcode%' or 'searchcode%' ;-)
0
 
kretzschmarCommented:
its % for sql-statement-where-clause
its * for filters, where it can only be appended

to barry,
i guess this does not work,
had tested it similar (not with a persistent field)
and get the error: Cannot access Field ... on Filter (or similar)
did you tested it?
i guess no, then you had post an answer :-))
meikl
0
 
JohnEAuthor Commented:
Raymond's answer works great. Is there a way to make it case insensitive?

Thanks

John
0
 
kretzschmarCommented:
i guess i was wrong ;-)
0
 
rwilson032697Commented:
How about this:

procedure TForm1.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean);

begin
  Accept := Pos(UpperCase('The string to search for'), UpperCase(DataSet['TheMemoField'])) > 0;
end;

You could factor out the uppercase-ing of the search string to make it a little faster...

Cheers,

Raymond.

0
 
JohnEAuthor Commented:
Thanks Raymond - works perfectly!
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 4
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now