Subject Re: [IBO] LookupCombo
Author Helen Borrie
At 01:17 PM 30-04-01 +0000, you wrote:

> Yes I dont have BDE installed I do use all IB_Objects controls. It
>is just getting my mind around various controls and their intended
>way of operation I find difficult.
>The ibojects dbcombo does not have a 'list source'

The architecture of the IB_ controls is quite different to that of the Delphi VCL. The IB_ datasets drive the behaviour of the controls. The "equivalent" of the ListSource and ListItem properties is achieved by using special properties to set up the "KeySource-Lookup" relationship.

The KeySource dataset is the one in which the lookup keys are stored. The Lookup dataset is a set containing one and only one row for each possible lookup key. It can contain keys which do not exist in any row of the KeySource set. Normally, you would use one lookup dataset for each lookup key in the KeySource set, i.e. the primary key column (or columns) of the lookup table and the associated description column.

If you use the Object Inspector to enter the linking properties (recommended, if you are setting this up at design time) then you will have these properties to set on the Lookup query:

KeyLinks
MyLkpQuery.IDField=MyKeySourceQuery.LookupID

KeySource
dsMyKeySourceQuery (selected from drop-down list)

If you wish, you can create a DEFAULT in the ColumnAttributes for the lookup key of the KeySource dataset. If that's the behaviour you want, just make sure there is a corresponding row in the Lookup set and the default will appear when the INSERT happens.

>so the queries
>have to be linked as you indicate, but at this point the main table
>holds a blank record apart from its primary key which is placed there
>from a generator. The combo is connected to the lookup table and is
>showing the list of town to select...what happens next ?

If you have this set up properly, and no DEFAULT defined for the lookup key in the KeySource set, the editbox portion of the ib_LookupCombo should just display a blank until the user picks something; and null will be stored in the lookup key field if the database allows it.

>I am using delphi4 and ib_query and ib_datasource for both tables as
>required.

>(When the user presses the 'check' button the data is transferred
>from the lookup to the main record...but this is no different from
>using non data-aware components).

No "button" action is required to "transfer" data: if the linking is correct, the relationship is formed in the datalinks and the selected lookup key will be placed where it belongs automatically. There is no handler code to write, as one does with non-data-aware controls....

Cheers,
Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________