Subject Re: [IBO] Problem with event OnChange -> IB_LookupCombo
Author Helen Borrie
Andrei,

At 11:29 AM 30/06/2005 -0300, you wrote:
>I'm trying to use this code on OnChange event of IB_LookupCombo:
>
>dm.qrSalesItems.FieldByName('Price').AsCurrency :=
>dmLookup.qrProductSales.FieldByName('Sale_Price').asCurrency;
>
>This IB_LookupCombo points to dmLookup.qrProductSales.
>
>The problem is: when I'm insert data in dm.qrSalesItems, and click
>IB_LookupCombo, the record are shown, but, I can't choose any!
>
>If I put the code on OnExit event of the same IB_LookupCombo, I can
>choose normally a product.
>
>Can't I use that code on OnChange event?

No. The dataset and its relationships drive the controls, not the other
way around. The ib_lookupcombo is designed specifically for matching a
unique lookup item with a non-unique value in the Keysource dataset. (The
Keysource dataset is the one that wants to get a value from the lookup).

The information you provide isn't adequate to tell what is wrong here, but
the minimum elements should be:

1) the lookup dataset's KeySource property must point to the datasource of
the SalesItems set.

2) the values in the lookup list must be unique and not null.

3) the field name of the unique value should occupy the left side of the
KeyLinks property, while the right side should contain the set-qualified
name of the Sales Details field that is to be linked to the lookup value:
i.e. Sale_Price=qrSalesItems.Price

If there are two members in the KeyLinks then they both must be present, e.g.
Sale_Price=qrSalesItems.Price
Product_ID=qrSalesItems.Product_ID

4) Mastersource, MasterLinks, etc. must not be enabled between these two sets

If this is unclear, provide the essential information about your KeySource
and KeyLinks settings.

>Using Delphi 4 + FB 1.5.2 + IBO 4.3

That should be OK.

Helen