Subject Re: Recursive call of TIB_LookupCombo.OnChange
Author tibotaka
--- In IBObjects@y..., Gabriel Juncu <gjuncu@c...> wrote:
> Hi List,
> I'm using IBO 4.2Fn and Delphi 6 and the following simple app:
> Two TIB_Querys: Qry and LookupQry, and a TIB_LookupCombo connected
to
> LookupQry and updating Qry. Everything works ok until:
> In LookupCombo.OnChange event, I put the following statement:
>
> Qry.FieldByName('SOME_FIELD').AsInteger := 1; //example only
> Note that SOME_FIELD is DIFFERENT from the field the LookupCombo
updates;
>
> ...
> Is there any way that I can assign a value to a Qry's field in the
OnChange
> event of the LookupCombo? (LookupQry contains some default values
for some
> fields in Qry, so when a user chooses a value in the Lookup , some
other Qry fields
> must be filled with the default values that the user can change
afterwards).
>
> Thank You!
> Gabriel

In my opinion far better way to fill default values of "Qry"
from "LookupQry" is in AfterScroll event of "LookupQry"...

Code snippet:

procedure Tfrm."LookupQry"AfterScroll(IB_Dataset: TIB_Dataset);
begin
inherited;
with IB_Dataset.KeySource.DataSet do <- this is "Qry"
begin
case State of
dssInsert,
dssEdit:
begin
"Qry"-> FieldByName('SOME_FIELD').AsString :=
"LookupQry"-> IB_Dataset.FieldByName('SOME_FIELD').AsString;
...etc...
end;
end;
end;
end;

I think OnChange event of LookupCombo is "too dangerous and confused"
for your needs... ;-)

Sorry for a bit long post, but I hope it helps...

Tibor