Subject Re: [IBO] Keysource & Master Relationships Problem
Author Bob
> Lading is your master here.

Right. I was careless with my use of the word "Master".

> The K/K relationship will cause the selected Lading to be written
> automatically to the keylinked column in the Keysource dataset (Ticket)
> (i.e. the behaviour that you were trying to force in your handler for the
> LookupCombo). The M/D relationship will cause the detail dataset to be
> restricted automatically to just those Bookings which pertain to the
> selected Lading.

What you describe above is exactly what I want. My LookupCombo wasn't trying
to assign the LadingID, but some other columns.

> It appears that you want the selection of Booking to drive which Lading
> be selected for a Ticket? Would you confirm this? or otherwise explain
> what you seek to do? If your ultimate aim is to tie Booking.OrigID with
> Ticket.CustID as well as Lading.LadingID with Ticket.LadingID then your
> current "raw" setup can't work.
The user, while editing a new Ticket, can select a Lading, which (through
M/D relationship) also gives me all Bookings (actually there's only one)
associated with the Lading.

Also, depending on whether the Ticket is for Purchase or Sale, I want to set
some fields in Ticket. Take a look at this:

qrTicket['RATE'] := qrBook['RATE'];
qrTicket['UNIT'] := qrBook['UNIT'];
if PurchSale.ItemIndex = 0 then begin
qrTicket['CONT_ID'] := qrBook['O_CONT_ID'];
qrTicket['CUST_ID'] := qrBook['ORIG_ID'];
end else begin
qrTicket['CONT_ID'] := qrBook['D_CONT_ID'];
qrTicket['CUST_ID'] := qrBook['DEST_ID'];

That's where I'm having my problems. Without the code above in the OnChange
event, the Lading lookup and M/D for Booking worked fine.

The user can override RATE and UNIT in the Ticket, which is why I copy them
over from Booking. For CONT_ID and CUST_ID, there's the variable of
Purch_Sale which changes which columns are used to evaluate tickets.

> That's true; and then the Bookings available will be only those that are
> detail to the selected Lading. If there is no Booking having an OrigID
> which matches the CustID in Ticket, you are stuck, since you would have to
> find a way to insert a new set of relationships, which isn't possible with
> this structure.
I don't understand how Booking.OrigID gets tied to Ticket.CustID. Of course
I know my code is there, but don't see how it's impacting the relationships
when OrigID and CustID weren't included in Keylinks or Masterlinks when I
set them up in the queries.

Thanks Helen.