Subject Re: [IBO] Search question
Author Harald Klomann
Nico Callewaert wrote:
>
> Hi,
>
> I have a form for searchedit connected to a query, in the OnPrepare
> statement, I have a line like this : .... SQLWhereItems.Add ('UPPER (NAME)
> STARTING WITH :NAME');
> Now a user is asking me if it is possible to search for a string not
> starting with, but like a substring.
> I think I can solve it with : .... SQLWhereItems.Add ('UPPER (NAME) IN
> :NAME'); ???
> Right ?

> Do I need 2 SearchEdit components for it ? In case if, if the user would
> switch between the 2 search modes, I guess I have to reprepare the statement
> with the right SQLWhereItems clause ?
> Or is there a better way for this ?
>
> Thanks,
>
> Nico Callewaert
>

Nico,

>> SQLWhereItems.Add ('UPPER (NAME) IN :NAME');

This will not work, use SQLWhereItems.Add ('UPPER (NAME) CONTAINING :NAME');

> But the problem then is, how will I make a difference between the 2, because
> user A will intend to look for a name STARTING WITH, and user B would like
> to search on a substring in that name.

Use a switch on your form, like a checkbox with the text maybe Starting with / Containing
In the OnPrepare statement, just evaluate the switch, like :


if CheckBox1.Checked then
SQLWhereItems.Add ('UPPER (NAME) STARTING WITH :NAME');
else
SQLWhereItems.Add ('UPPER (NAME) CONTAINING :NAME');


Harald