Subject Re: [IBO] Cannot get TIB_LookupCombo to work as expected .. I know its my fault!
Author Helen Borrie
At 12:20 PM 20/11/2004 +0200, you wrote:

>I have a Query called IB_QueryANIMAL
>
>I have a field in the ANIMAL table called LOCATION.
>
>I have a LOCATION table, with a field called LOCATION, with IB_QueryLOCATION
>(Select * from LOCATION)
>
>
>I would like to display the contents of TABLE location in a LookupCombo, for
>entry into table ANIMAL
>
>
>
>The DBLOOKUPCOMBO gives a ListSource, and a Datasource.
>
>IF using DBLookupCombo for above then I would set the ListSource to point to
>LOCATION table, and Datasource to point to ANIMAL table, and two ticks later
>all working wonderfully easily.
>
> TIB_LookupCombo, only has DataSource, and DisplayField.

Remember, in IBO, datasets drive controls, not the other way around as in
the VCL model.

Link the TIB_LookupCombo's Datasource property to the TIB_Datasource of
your Location query.

Pick the field you want to display in the editbox part of the control as
DisplayField.

Everything else happens on the dataset of the Location query.


>How many IB_Queries do I need.?
>
>How do I set up the Master child relationship?

It's not a Master child relationship. It is what is referred to as a
KeySource/Lookup relationship.


>How does the loopupCombo know to insert the data into IB_QueryAnimal once
>the selection has been made .. I cannot find a way to bind it to ANIMAL.

It doesn't. You can't use a TIB_LookupCombo to implement a master-detail
relationship.


>Just get it to display the lookup data, but with no effect on animal.

Please explain exactly what you want. The TIB_LookupCombo implements a
lookup relationship. That is, the primary key of the lookup table, e.g.
LocationID, points to a polling key in the main table - the "Keysource"
table - which is designed (by you) to point to the location. It can be that
many Animal records would point to the same LocationID through this lookup key.

If that is what you want to implement, then proceed like this with the
Location query object, assuming that the name of the key is LocationID.

Do as I described earlier with the Datasource and DisplayField properties
of the control.

For the KeySource property, select the Datasource (must be a
TIB_Datasource) that points to the main table.

For the KeyLinks property, type in
LOCATIONID=ANIMAL.LOCATIONID

If you want the ability to type in some characters of the Location
description (the DisplayField) and have the mechanism find the key, set
KeySeeking true (I think it is the default, anyway).

Now, if you want to go further, and link up the lookup dataset's
description field, ie. the DisplayField, to a derived field in main
dataset, you use KeyDescLinks as well. There is more to this and I won't
waste space and time if you don't need this (i.e. you only want to use the
LocationID in the main dataset).

Lastly, if you want to, you can proceed to embed the lookupcombo in the
grid. To do that, select it and cut it out using Ctrl-X. Then, select the
grid by clicking in it, and do Ctrl-V to drop the control into the
grid. Then, when you run your program, the lookupcombo will appear in
place of the polling key field when that field gets focus in dssEdit or
dssInsert and you will be able to select a value for LocationID in the main
dataset.

Helen
>