Subject Re: [IBO] TIB_Quert property Ordering Items
Author Geoff Worboys
> Lookbook has an unsorted result if the order is set at run
> time with the onbeforeprepare event handler, but is sorted
> if the Order By is hard coded in the sql property of
> sqllookbook. Why isnt the onbeforeprepare handler being
> called(or actioned )?

It seems I may have been a bit mistaken in my previous posting. I
have never used SQLOrder before, I've always managed to get by with
the Ordering* properties.

So, ignore what I said about using OnPrepareSQL. Sorry about that. I
was thinking it worked like the SQLWhereItems - which only operate
within the OnPrepareSQL.

SQLWhereItems can be used inside OnPrepareSQL to add subclauses to the
where statement dynamically during a prepare. Such additions are NOT
made to the primary SQL statement.


SQLOrder (and related properties) can be used to change the particular
clause of the SQL statement itself! These properties change the
entire clause of the SQL property and so must be handled with care and
fully defined.

According to my experimentation, to change the order clause you would
need to *replace* the property not add to it. So your code should
be...
SQLOrder.Text := 'ORDER BY BOOKREF';


Having said that. This is entirely inappropriate for use with
TIB_LookupDialog (or anywhere you are using a grid with sort
indicators), since the grid sort indicators use the Ordering*
properties to determine the current and possible sort orders.


Sorry about the initial misunderstanding. I may have been using IBO
for years but there are still chunks of it I have never had to use :-)

Geoff Worboys
Telesis Computing