Subject Re: [IBO] Lookup on Client table
Author Tony Masefield
--- In IBObjects@yahoogroups.com, "Alan McDonald" <alan@...> wrote:
>
> > Hi All,
> >
> > Using IBO/FB I have two tables, master/client. Requestlive set
to true
> > on both.
> > Both have PK fields. Client has FK field on master PK. PK fields
are
> > autogenerated (Using GeneratorLinks - a standard integer) fields
for
> > both tables.
> > Everything works according to plan.
> >
> > If I add a lookup to the client based on it's FK refering to
> > the 'SupplierName' mastertable field I get a "Field X must have a
> > value" when attempting an insert on the client - where Field X
is a
> > required field for the client (there are 4 required fields in
total).
> > What I don't understand is why using INSERT seems to generate a
POST -
> > which is where I anticipate the error comes from as would be
expected
> > for a 'not null' field.
> > Suggestions/workaround?
> >
> > Regards
>
> in your AfterInsert event, give the required fields a value
> E.G.
> IB_Dataset.FieldByName('ID').AsInt64 :=
> IB_Dataset.Gen_ID('GEN_ERATOR_ID',10);
>
> FKs are allowed to be NULL if you make them nullable on the
database.
>
> Alan
>
Hi Alan, we may be talking at cross purposes. The master record
exists but hitting INSERT on the detail table gives the error prior
to trying to post. This only occurs if the Detail table fkLookup
field is set to type lookup in the fields editor (which it should
be). Removing the fklookup field the app works (one can enter the
required and other fields). The FK field is set to the Master PK
field and the autogenerated PK detail field is filled in by the
generator.
All cool until I try add an fkLookup filed which references (via the
FK detail field) the PK field of the master to provide the (in this
case) 'Supplier_Name' field of the master as the 'ResultField'.
there is no explicit post, just an insert. An error is returned
which says 'FieldX (a 'Not Null' field) is required' - which seems
that this technique is trying (some way or another) to execute an
imlicit POST when INSERT is hit.
As mentioned, without the lookup field in the detail all's fine and
behaviour is as expected.
The lookup field in the master is, in reality, just a 'label' for
the detail table ('Supplier Contacts'). The master is diplayed as a
grid and the detail as a 'Card View' - like DBCtrlGrid but based on
Express QuantumGrid if you are familiar with this component.

Thanks for the help, especially on Sunday (working day here though).

Regards,