Subject Re: [IBO] How can I...
Author Helen Borrie
Andre,

You didn't send the Keylinks for the lookup data but I am assuming
(a) the lookup for BEN_LANGUE has
ITEMCODE=ADMISSIONTEMPORAIRE.BEN_LANGUE
and
(b) you have another (separate) lookup for BEN_LANGUE2 that has the same SQL as the one for BEN_LANGUE and has Keylinks of
ITEMCODE=ADMISSIONTEMPORAIRE.BEN_LANGUE2

You wrote:

>For example this will put ITEMCODE in the field BEN_LANGUE.
>
>[snipped procedure, looks ok]


>then I do this:
>
> with IBSP_BenInfo do
> begin
> if Prepared then UnPrepare;
> Prepare;
> ParamByName('IN_BENNO').asString := IBE_NoDossier.Field.Value;
> ExecProc;
> if ParamByName('BEN_NOBENEFICIAIRE').AsString <> '' then
> begin
> IBE_Nom.Field.Value := ParamByName('BEN_NOM').AsString;
> IBE_Prenom.Field.Value := ParamByName('BEN_PRENOM').AsString;
> IBE_NAM.Field.Value := ParamByName('BEN_NAM').AsString;
> IBE_NAS.Field.Value := ParamByName('BEN_NAS').AsString;
> IBLC_Sexe.DataSource.Dataset.FieldByName('BEN_SEXE').AsString := ParamByName('BEN_SEXE').AsString;
> IBE_DateNaissance.Field.Value := ParamByName('BEN_DATENAISSANCE').AsString;
> IBE_NomPere.Field.Value := ParamByName('BEN_NOMPERE').AsString;
> IBE_NomMere.Field.Value := ParamByName('BEN_NOMMERE').AsString;
> IBE_LieuNaissance.Field.Value := ParamByName('BEN_LIEUNAISSANCE').AsString;
> IBLC_Langue.DataSource.Dataset.FieldByName('BEN_LANGUE').AsString := ParamByName('BEN_LANGUE').AsString;
> IBLC_Langue2.DataSource.Dataset.FieldByName('BEN_LANGUE2').AsString := ParamByName('BEN_LANGUE2').AsString;
> end; // not ParamByName('OUT_NOBEN').IsNull
> end; // with IBSP_BenInfo
>
>fields with starting with IBLC are Lookup Combo.

OK, first, it is not correct to assign these values to the controls - you should assign them to the dataset columns. The data-aware controls will simply follow the dataset.

Second, the BEN_LANGUE and BEN_LANGUE2 values that you get back from your SP should go into the main dataset. The main dataset will then search out to the two lookup datasets and these will be positioned correctly on the row (in each) that the two lookup keys are pointing to.

Assuming you have the new row for the main query in dssInsert (and I'm just guessing that your main/keysource query is called qryMain):

...
with IBSP_BenInfo do
begin
qryMain.FieldByName('BEN_NOM').AsString := ParamByName('BEN_NOM').AsString;
qryMain.FieldByName('BEN_PRENOMNOM').AsString := ParamByName('PRENOM').AsString;
...
...
qryMain.FieldByName('BEN_LANGUE').AsString := ParamByName('BEN_LANGUE').AsString;
qryMain.FieldByName('BEN_LANGUE2').AsString := ParamByName('BEN_LANGUE2').AsString;
...

Do you see the differences here?

Regards,
Helen

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