Subject Re: [IBO] Altering values in search mode

Thanks a Lot.


>Hi Luiz,
>> Is there a way to modify the values to be searched to this
>> column("BIRTDATE") before the search is performed?
>There are some features built into IBOs TIB_DataLink and
>TIB_FieldDataLink classes. They are mostly there for derived
>but can make use of via the OnPrepareSQL event of the control.
>First you need to realise that "search values" are just string
>buffers, they have not been interpretted to actual numbers or dates
>anything. They normally processed as strings into a where clause.
>When you attach code to OnPrepareSQL for a control you disable the
>default processing of the search entry (it still exists but is not
>used to modify the actual dataset SQL where clause).
>In the simplest example you could do something like...
>procedure IB_Edit1PrepareSQL(Sender: TIB_DataLink;
> ADataSource: TIB_DataSource);
> if Sender.SearchBuffer <> '' then
> Sender.AdvSearchWhere := 'MYFIELD=' + Sender.SearchBuffer
> else
> Sender.AdvSearchWhere := '';
>Anything you assign to AdvSearchWhere is used like this...
> if AdvSearchWhere <> '' then begin
> Dataset.SQLWhereItems.Add( AdvSearchWhere );
> end;
>So you simply assign some valid SQL clause to AdvSearchWhere and it
>will be added as required.
>In your example I imagine you will have to parse the searchbuffer
>(what the user typed into the control) into something appropriate
>and then build the necessary SQL where clause from the result.
>See also the AdvSearch* properties in the online help, and if you
>interested in seeing how it works in derived controls my
>IB_ComboBoxEnh and IB_LookupEnh controls use these properties