Subject Re: [IBO] Keysource & Master Relationships Problem
Author Bob
> Try it, anyway. Unfortunately, I'm flat-out at the moment so can't set up
> a test app to verify that this will work. The crucial thing will be
> whether the new value is available at the start of this event...I'm pretty
> sure it is, since IsModified is available.

Well, we're getting closer. This is what I have.

procedure TTicket.dsTicketDataChange(Sender: TIB_StatementLink;
Statement: TIB_Statement; Field: TIB_Column);
begin
if Field <> nil then begin
ShowMessage('FieldName='+Field.FieldName);
if (Field.FieldName = 'LADING_ID') and (Field.IsModified) then
begin
with Statement as TIB_Query do
begin
FieldByName ('RATE').AsFloat :=
qrLading.FieldByName('RATE').AsFloat;
FieldByName ('UNIT').AsString :=
qrLading.FieldByName('UNIT').AsString;
if PurchSale.ItemIndex = 0 then begin
FieldByName ('CONT_ID').AsInteger :=
qrLading.FieldByName('O_CONT_ID').AsInteger;
FieldByName ('CUST_ID').AsString :=
qrLading.FieldByName('ORIG_ID').AsString;
end else begin
FieldByName ('CONT_ID').AsInteger :=
qrLading.FieldByName('D_CONT_ID').AsInteger;
FieldByName ('CUST_ID').AsString :=
qrLading.FieldByName('DEST_ID').AsString;
end;
end; {with}
end;
end;
end;

Here's the funny thing. The code works if the LookupCombo is displaying
LADING_ID. However, even though LADING_ID is the link between Ticket and
Lading, I want to display LADING_NUM in the LookupCombo. So I make
qrLading.KeyDescLinks as LADING.LADING_NUM=LAD_NUM and change
LookupCombo.DisplayField=LADING_NUM (instead of LADING_ID). However when the
DataChange event fires, Field comes through as nil.

In short, when KeyDescLinks is set, Field comes through as nil.

What do you think?

Bob.
-------------------------------
qrLading has KeyLinks of LADING.LADING_ID=TICKET.LADING_ID.

qrTicket is
SELECT CARRIER
{ some fields }
, PUR_SALE
, CONT_ID
, CUST_ID
, COMM_ID
, UNLOAD_T_ID
, LADING_ID
, (SELECT LADING_NUM FROM LADING L
WHERE T.LADING_ID=L.LADING_ID)
AS LAD_NUM
FROM TICKET T

LookupCombo is
DataSource = dsLading
DataField = LADING_NUM