Subject | Re: [IBO] Helen .. perhaps this is clearer |
---|---|
Author | Helen Borrie |
Post date | 2004-11-20T14:22:06Z |
Adrian,
Reading your two responses, I see where the comprehension problem
lies. You stated that you wanted to use the lookup to "insert data" into
the main dataset. That was saying to me that you somehow wanted the action
of the lookupcombo to cause a row to be inserted. Now it seems you were
using the term "insert" to mean "write a value".
I think you DO actually want to implement a Keysource/Lookup relationship.
At 01:36 PM 20/11/2004 +0200, you wrote:
Guessing...
create table animal (
animalID integer nn pk,
species integer,
.....,
locationID integer)
create table location (
locationID integer nn pk,
description varchar(20))
1 here
2 there
3 anywhere
animalID LocationID
1 1
2 1
3 2
4 3
5 1
6 3
7 2
not the question in hand.
except you don't drop it into a grid - use it as a stand-alone control, in
place of the tib_edit you would otherwise have there.
select
a.animalID,
a....,
a.locationID,
(select L.description from Location L
where L.LocationID = a.LocationID) as Loc_Name
from Animal a
where....whatever
Suppose qrLoc has this SQL:
select
LocationID,
Description
from Location
Right. Drop in the two datasources, dsAnimal hooked to qrAnimal, dsLoc
hooked to qrLoc.
Drop in the tib_lookupcombo. Set its datasource to dsLoc, set DisplayField
to Description.
Now, move to qrLoc.
KeySource: dsAnimal
KeyLinks: LocationID=qrAnimal.LocationID
KeyDescLinks: Description=Loc_Name
KeySeeking := True
Now, qrAnimal:
KeyLinks: AnimalID
RequestLive: True
Done.
Helen
Reading your two responses, I see where the comprehension problem
lies. You stated that you wanted to use the lookup to "insert data" into
the main dataset. That was saying to me that you somehow wanted the action
of the lookupcombo to cause a row to be inserted. Now it seems you were
using the term "insert" to mean "write a value".
I think you DO actually want to implement a Keysource/Lookup relationship.
At 01:36 PM 20/11/2004 +0200, you wrote:
>Lets say I have ANIMAL table, with field called location.?
>
>Thisa field stores where the animal finds itself.
Guessing...
create table animal (
animalID integer nn pk,
species integer,
.....,
locationID integer)
create table location (
locationID integer nn pk,
description varchar(20))
>Location could have values eg: here, there, anywhere.LocationID Description
1 here
2 there
3 anywhere
animalID LocationID
1 1
2 1
3 2
4 3
5 1
6 3
7 2
>Now I could insert these values using a IB_COMBOBOX, with the dataset setNot necessarily; I populate comboboxes from tables very often; but that's
>to Animal table, and the field to location, and a stringlist which contains
>"here, there, anywhere".
>This is however a hardcoded method for static variables..
not the question in hand.
>Thus I created table location, for the user to add their own locations eg:It can be used this way. It's just as I described in the earlier message,
>
>"CampB, CampC, CampD"
>
>And now I would like to insert values from LOCATION table using a dropdown
>list into the ANIMAL tables location field for every animal.
>
>
>Perhaps IB_LOOKUPCOMBO is not the correct component to use?
except you don't drop it into a grid - use it as a stand-alone control, in
place of the tib_edit you would otherwise have there.
>How would you suggest I go about this.Suppose qrAnimal has this SQL :
select
a.animalID,
a....,
a.locationID,
(select L.description from Location L
where L.LocationID = a.LocationID) as Loc_Name
from Animal a
where....whatever
Suppose qrLoc has this SQL:
select
LocationID,
Description
from Location
Right. Drop in the two datasources, dsAnimal hooked to qrAnimal, dsLoc
hooked to qrLoc.
Drop in the tib_lookupcombo. Set its datasource to dsLoc, set DisplayField
to Description.
Now, move to qrLoc.
KeySource: dsAnimal
KeyLinks: LocationID=qrAnimal.LocationID
KeyDescLinks: Description=Loc_Name
KeySeeking := True
Now, qrAnimal:
KeyLinks: AnimalID
RequestLive: True
Done.
Helen