Subject Re: [IBO] RefinedSQL and assigning problem
Author Helen Borrie
At 04:22 PM 8/09/2005 +0000, you wrote:
>Hi all,
>I am trying to execute the statement(s):
>(TIB_Query's, IB 4.5B, D5 Ent)
>SecMasterQuery.SQL.Text := MasterQuery.RefinedSQL;
>SecDetailQuery.SQL.Text := DetailQuery.RefinedSQL;
>but right after assigning this value the My_Query
>SQL text does not show any change. Could there be
>any settings that would prevent setting this text?

You should never try to "assign" a statement by setting the SQL.Text
property. This doesn't just go for the TStrings classes that IBO uses,
it's a general rule for TStrings. Although the Text property of a TStrings
is writable, it is almost never used for writing. The class is designed to
*deliver* a string based on the content of the indexed strings within.

To pass the current SQL from one statement object to another, use

>I am trying to work a basic invoice type system where
>there is one master and many detail records. After
>selecting one master record and linking the details,
>using masterlink/mastersource, I then also try to filter
>out some of the detail records using a TIB_SearchPanel and
>the resulting RefinedSQL text.
>After performing the filtering I then carry the master's
>SQL statement over to a second pair of TIB_Query components
>linked in the same way as the main two.
>After I carry the DetailQuery's SQL over, though, it refuses
>to make any changes to the second SQL statement, SecDetailQuery.
>Any ideas?

See above.

Make sure that both datasets are in a condition where reassignment of the
SQL property is logically possible. For example, if you are re-assigning
the SQL of two dependent statements, then don't try to prepare or open one
before you have attended to the other.

The right place to do these changes is in the OnPrepareSQL event. That
means that the decision to change, e.g. a button-click event, must not
occur at a point where something else is going on, like part-way through an
edit or search operation. Ensure that the statement is actually going to
be prepared as a result of what your button-click does; otherwise there is
no OnPrepareSQL event and there will be no certainty about the state of the