Subject Re: [IBO] Keysource & Master Relationships Problem
Author Helen Borrie (TeamIBO)
At 05:07 PM 22-05-02 -0500, you wrote:
> > I hope you can see how the cross-linked relationships are causing this
> > snafu. Applying values to ticket from the selected Booking row is no
> > problem. If there is a forced 1:1 relationship between Lading and
> > as seems apparent, then don't Keylink Lading to Ticket. Put it in a Combo
> > (not a LookupCombo) and use it as a selector for a Booking structure which
> > joins Lading and Booking and supplies the values to Ticket. You can then
> > masterlink this joined structure to Ticket through its Lading_ID.
>I don't *exactly* see how they're causing my problems, though I do see that
>I have a confusing setup. How about this: I've eliminated the M/D between
>Lading and Booking and replaced it with a join (see below). I left the
>LookupCombo attached between Ticket and Lading/Booking (tied on LADING_ID)
>so the user can select a Lading (and its associated Booking).

From a data point of view, it should work.
> This is the code I want to run when the user selects a Lading.

Next thing to do is fix your assignment code:
with qrTicket.Fields do
ByName ('RATE').AsFloat := qrLading.FieldByName('RATE').AsFloat;
ByName ('UNIT') := qrLading.FieldByName('UNIT').AsString;
if PurchSale.ItemIndex = 0 then begin
ByName ('CONT_ID').AsInteger := qrLading.FieldByName('O_CONT_ID').AsInteger;
ByName ('CUST_ID').AsInteger := qrLading.FieldByName('ORIG_ID').AsInteger;
end else begin
ByName ('CONT_ID').AsInteger := qrLading.FieldByName('D_CONT_ID').AsInteger;
ByName ('CUST_ID').AsInteger := qrLading.FieldByName('DEST_ID').AsInteger;

However, I think you should keep away from the OnChange event of the
control. Try to see if you can get at the OnDataChange of qrTicket's
datasource this way:

procedure TForm1.IB_DataSource1DataChange(Sender: TIB_StatementLink;
Statement: TIB_Statement; Field: TIB_Column);
if Field.Name = 'LADING_ID' and Field.IsModified then
with with Statement as TIB_Query do
FieldByName ('RATE').AsFloat := qrLading.FieldByName('RATE').AsFloat;
FieldByName ('UNIT') := qrLading.FieldByName('UNIT').AsString;
if PurchSale.ItemIndex = 0 then begin
FieldByName ('CONT_ID').AsInteger :=
FieldByName ('CUST_ID').AsInteger :=
end else begin
FieldByName ('CONT_ID').AsInteger :=
FieldByName ('CUST_ID').AsInteger :=

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.

Helen Borrie (TeamIBO Support)

** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at