Solved

Search a memo using onfilterrecord

Posted on 2000-02-29
10
201 Views
Last Modified: 2010-04-04
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
Comment
Question by:JohnE
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2571649
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2571826
i guess that is not possible :-(
0
 
LVL 15

Expert Comment

by:simonet
ID: 2572048
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 2572063
alex, i guess this will also not work for blobs
0
 
LVL 17

Expert Comment

by:inthe
ID: 2573777
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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2573892
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
 

Author Comment

by:JohnE
ID: 2574220
Raymond's answer works great. Is there a way to make it case insensitive?

Thanks

John
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2574245
i guess i was wrong ;-)
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 100 total points
ID: 2574289
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
 

Author Comment

by:JohnE
ID: 2574334
Thanks Raymond - works perfectly!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question