Subject RE: [IBO] Re: Adding search criteria to WHERE clause and more..not working as expected.
Author Adrian Wreyford
Thanks Michael

It works .. but still not sure why. I think it works as follows?

So it appears the SQLWhere clause only holds the Search SQL that was
assigned, but when the SQL for the Query is prepared for sending to the
server for execution, then the SQLWhereItemsAdd part you assigned so
elegantly, is actually added to the where clause.



Again .. Thanks for the prompt and complete answer!



Adrian



_____

Michael Wrote:
Declare an OnPrepareSQL event handler:

procedure <suitable object>.RestrictToDOB(Sender: TObject);
begin
(Sender as TIBODataset).SQLWhereItems.Add('ANIMAL.ANIMALDOB
BETWEEN ''' +
DateToStr(DTPBeg.Date) + ''' AND ''' + DateToStr(DTPEnd.Date)
+ ''' ');
end;

Then assign it:

IBOQuery1.OnPrepareSQL := <instance of the suitable
object>.RestrictToDOB;

I don't think you need to do this Prepare any more:
>
> IBOQuery1.Prepare;
>

Do this, though (I think the OnPrepareSql event gets called as a
result of this).
> IBOQuery1.AssignSQLWithSearch(IB_Query1);
> IBOQuery1.Open;
>

Michael D. Spence



[Non-text portions of this message have been removed]