Subject | Re: Only one Lookup-Query for several different Datasets |
---|---|
Author | Marco Menardi <mmenaz@lycosmail.com> |
Post date | 2003-02-09T13:46:33Z |
I use the following code:
procedure TdmAnagrafiche.ChangeGenericLookupSource(
LookupDataset: TIB_DataSet; AKeySource: TIB_DataSource; AKeyLink:
string; AKeyDescLink: string = ''; AddSettings: boolean = False );
begin
with LookupDataset do
begin
Close;
KeySource := AKeySource;
if not AddSettings then
begin
KeyLinks.Clear;
KeyDescLinks.Clear;
end;
if AKeyLink <> '' then KeyLinks.Add(AKeyLink);
if AKeyDescLink <> '' then KeyDescLinks.Add(AKeyDescLink);
Prepare;
Open;
end;
end;
then, in the FormCreate event, I associate that "generic lookup" query
to what I need, like:
ChangeGenericLookupSource( qryGLkBanche,
IB_SearchBar1.DataSource,
'BANCHE.BANCA_ID=FORNITORI.BANCA_ID' );
or
ChangeGenericLookupSource( qryGLkFornitoriCategorie,
dsrAnFornitori_U_Categorie,
'FORNITORI_CATEGORIE.CATEGORIA_ID=FORNITORI_U_CATEGORIE.CATEGORIA_ID',
'FORNITORI_CATEGORIE.DESCRIZIONEDISP=PT_DESCRIZIONE_CATEGORIA' );
it works very well for me
regards
Marco Menardi
procedure TdmAnagrafiche.ChangeGenericLookupSource(
LookupDataset: TIB_DataSet; AKeySource: TIB_DataSource; AKeyLink:
string; AKeyDescLink: string = ''; AddSettings: boolean = False );
begin
with LookupDataset do
begin
Close;
KeySource := AKeySource;
if not AddSettings then
begin
KeyLinks.Clear;
KeyDescLinks.Clear;
end;
if AKeyLink <> '' then KeyLinks.Add(AKeyLink);
if AKeyDescLink <> '' then KeyDescLinks.Add(AKeyDescLink);
Prepare;
Open;
end;
end;
then, in the FormCreate event, I associate that "generic lookup" query
to what I need, like:
ChangeGenericLookupSource( qryGLkBanche,
IB_SearchBar1.DataSource,
'BANCHE.BANCA_ID=FORNITORI.BANCA_ID' );
or
ChangeGenericLookupSource( qryGLkFornitoriCategorie,
dsrAnFornitori_U_Categorie,
'FORNITORI_CATEGORIE.CATEGORIA_ID=FORNITORI_U_CATEGORIE.CATEGORIA_ID',
'FORNITORI_CATEGORIE.DESCRIZIONEDISP=PT_DESCRIZIONE_CATEGORIA' );
it works very well for me
regards
Marco Menardi
--- In IBObjects@yahoogroups.com, "Florian Hector" <FHector@w...> wrote:
> Hi All,
>
> is it at all possible to use only one lookup-query for several different
> datasets?
> What I have tried so far, is assigning Keysource and Keylinks of the
> lookup-query to match the dataset in use. When I then want to select
a value
> from the lookupcombo, it remains empty.
>
> Florian