Subject | Re: [IBO] Altering values in search mode |
---|---|
Author | TeamIBO |
Post date | 2002-02-13T03:23:50Z |
Hi Luiz,
TIB_FieldDataLink classes. They are mostly there for derived controls
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 or
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);
begin
if Sender.SearchBuffer <> '' then
Sender.AdvSearchWhere := 'MYFIELD=' + Sender.SearchBuffer
else
Sender.AdvSearchWhere := '';
end;
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 text
(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 are
interested in seeing how it works in derived controls my
IB_ComboBoxEnh and IB_LookupEnh controls use these properties
internally.
hth
--
Geoff Worboys - TeamIBO
Telesis Computing
> Is there a way to modify the values to be searched to thisThere are some features built into IBOs TIB_DataLink and
> column("BIRTDATE") before the search is performed?
TIB_FieldDataLink classes. They are mostly there for derived controls
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 or
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);
begin
if Sender.SearchBuffer <> '' then
Sender.AdvSearchWhere := 'MYFIELD=' + Sender.SearchBuffer
else
Sender.AdvSearchWhere := '';
end;
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 text
(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 are
interested in seeing how it works in derived controls my
IB_ComboBoxEnh and IB_LookupEnh controls use these properties
internally.
hth
--
Geoff Worboys - TeamIBO
Telesis Computing