Subject Re: [IBO] Sometimes Detailqueries disappear
Author Helen Borrie
At 12:51 PM 01-12-00 +0100, you wrote:
>In my application I have up to 200 IB_Queries and all work fine. But
>with one Query I have to fight with a strange phenomenon. It is a
>masterquery with 7 detailqueries, which are assigned to the masterquery
>over the KeySource-property. All KeyLinks-Strings are correct (believe
>me, I have proofed them 100 times). The masterquery is assigned to a
>IB_UpdateBar. When I press the Editbutton and then the Savebutton,
>without changing the dataset, sometimes one of Detailqueries disappear.
>This means, the IB_Lookupcombo, which is assigned to the detailquery,
>becomes empty. The problem is, that this happens only sometimes and when
>it happens, it is every time another detailquery. I have replaced all
>detailqueries and the masterquery, but this doesn't help. Has anybody
>experienced something similar ?

Guido,
Your problem might be related to the fact that KeySource does not form
master-detail relations, it is for KeySource-Lookup relations. The
difference is that in a m/d relationship, you can have many detail rows
associated with one master; whereas, at any given point, there is a 1:1
relationship between a Keysource row and a Lookup row. To form
master-detail relationships, you need to use Mastersource and MasterLinks,
together with a normal, single KeyLinks entry for the detail dataset.

A problem such as you describe could arise where the lookup table contains
more than row that could complete the relationship; or where there is no
matching row in the lookup table.

You could get this ambiguity if your lookup dataset is using a join to
populate itself. For the special "dual" Keylinks to work, the relationship
must be unary and unique, and is normally expressed in the Lookup dataset as

MyUniqueID=TheSourcetable.LookupID

If you have a join in the lookup table AND you are certain that the lookup
dataset can not have more than one row with a matching ID, you might try

TheLookupTable.MyUniqueID=TheSourceTable.LookupID

I'm not sure whether naming both tables will throw an error, but it would
be worth a try. BTW, it must be the TABLE name that you use, not the
dataset name. I have a vague recollection that it DOES throw an error if
you include the lookup table name and I got around it by replacing the
lookup with a SELECT DISTINCT view.

Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________