Subject AW: [IBO] TIB_ComboBox / TIB_LookupCombo
Author Queck Rainer
Hello Paul,

thanks a lot for your instructions! They seem to "mostly" work except that I get a exception "field name tls_line_stop.ls_lsr_id was not found" when I enter the cell for lsr_reason_text and select a item from the combobox (showing up nicely as you described).

following your instructions, here is what I did:
I set up a Query "QLineStop":

SELECT LS_START_DATE_TIME, LS_END_DATE_TIME,
LSR_REGION, LSR_REASON_TEXT
FROM TLS_LINE_STOP
LEFT OUTER JOIN TLSR_LINE_STOP_REASON
ON LS_LSR_ID=LSR_ID

then I setup a other query "QLineStopReasons":

SELECT lsr_id,lsr_region, lsr_reason_text
FROM TLSR_LINE_STOP_REASON
ORDER BY lsr_reason_text

then I set the QLineStopReasons.KeySource to "DSLineStop" wich is my Datasource for QLineStop.

next I set QLineStopReasons.KeyLinks to : "lsr_id=tls_line_stop.ls_lsr_id"

next QLineStopReasons.KeyDescLinks to : "lsr_reason_text=LS_LSR_ID"

What am I doing wrong?

Regards
Rainer

P.S. I have to leave the office now. I am looking forward to your help tomorrow.




-----Ursprüngliche Nachricht-----
Von: Paul Vinkenoog [mailto:paul@...]
Gesendet: Dienstag, 4. November 2003 16:06
An: IBObjects (E-Mail)
Betreff: Re: [IBO] TIB_ComboBox / TIB_LookupCombo


Hello Rainer,

> CREATE TABLE TLSR_LINE_STOP_REASON (
> LSR_ID INTEGER NOT NULL,
> LSR_REGION CHAR(80),
> LSR_REASON_TEXT CHAR(255)
> );

> CREATE TABLE TLS_LINE_STOP (
> LS_ID INTEGER NOT NULL,
> LS_START_DATE_TIME TIMESTAMP,
> LS_END_DATE_TIME TIMESTAMP,
> LS_LSR_ID INTEGER
> );
>
> Where LS_LSR_ID is a foreign key referencing LSR_ID.
>
> What would be the best way to let a user select a
> TLSR_LINE_STOP_REASON for the TABLE TLS_LINE_STOP?
>
> A combobox with TLSR_LINE_STOP_REASON.LSR_REASON_TEXT as the Items
> with the selected LSR_ID beeing placed into TABLE
> TLS_LINE_STOP.LS_LSR_ID would be great, but how can I achieve this?

This is a classic case of a KeySource-Lookup relation. You set it up
like this:

- Set up an IB_Query QryLineStop on table TLS_LINE_STOP, but include
lsr_reason_text also, either by a subselect or by a join.
(If you use a join, you must set QryLineStop.KeyRelation to
TLS_LINE_STOP or the query won't be updateable.)

- Set up another query QryLineStopReasonLU with this SQL:
select lsr_id, lsr_reason_text from tlsr_line_stop_reason
order by lsr_reason_text // not necessary, but nice for the user

- Set QryLineStopReasonLU.KeySource to the DataSource of QryLineStop.

- Set QryLineStopReasonLU.KeyLinks to:
lsr_id=tls_line_stop.ls_lsr.id

- Set QryLineStopReasonLU.KeyDescLinks to:
lsr_reason_text=reason
( for "reason", you take the name that the joined or subselected
column has in QryLineStop.SQL ! )

- Preferably make lsr_id invisible in QryLineStopReasonLU.

- Drop an IB_LookupCombo on your form. Set its DataSource to the
DataSource of QryLineStopReasonLU. Set its DisplayField to
lsr_reason_txt.

Now everything works automagically after preparing and opening the
queries. Even better: instead of just somewhere on the form, you can
drop the IB_LookupCombo right on the grid connected to QryLineStop (if
you have one). Don't worry about how it looks at design time. At
runtime, the LookupCombo will be hidden until the user selects a cell
in the "reason text" column. Then the combo will align itself to the
cell, become visible and allow the user to select a reason.


Greetings,
Paul Vinkenoog



Yahoo! Groups Sponsor

ADVERTISEMENT
<http://rd.yahoo.com/M=267637.4116719.5338353.1261774/D=egroupweb/S=1705007183:HM/A=1754451/R=0/SIG=11tpj98m3/*http://www.netflix.com/Default?mqso=60178323&partid=4116719> click here
<http://us.adserver.yahoo.com/l?M=267637.4116719.5338353.1261774/D=egroupmail/S=:HM/A=1754451/rand=607039987>

___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .




[Non-text portions of this message have been removed]