Board index » delphi » Lookup field and filters

Lookup field and filters

Is it possible to apply a filter to a lookup field?
My table has three lookup fields (String type), but if I try to filter the
dataset using these fields I can't get any record.
Thanks
 

Re:Lookup field and filters


Quote
>Is it possible to apply a filter to a lookup field?
>My table has three lookup fields (String type), but if I try to filter the
>dataset using these fields I can't get any record.

No not with the filter property.  You can write an OnFilterRecord event handler
and with code find the lookup value to determine if the record is filtered.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Lookup field and filters


I have tried something like that and it doesnt work.

I have a Table (Table A) component with a lookup field obtained from another
table component. I have set the Filtered property of Table A to true and
written its OnFilterRecord event handler. But when the OnFilterRecord event
occurs, the lookup field has not got its value yet (it has always a value of
ASCII(1)). It seems that the lookup field get its value after the
OnFilterRecord event. How can I filter this field?

By the way, I am usind Delphi 4 and Access 97.

Brian Bushay TeamB <BBus...@Nmpls.com> escribi en el mensaje de noticias
mm1o4tstrih7fp6dvuerd0h55et7g5l...@4ax.com...

Quote

> >Is it possible to apply a filter to a lookup field?
> >My table has three lookup fields (String type), but if I try to filter
the
> >dataset using these fields I can't get any record.
> No not with the filter property.  You can write an OnFilterRecord event
handler
> and with code find the lookup value to determine if the record is
filtered.

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:Lookup field and filters


Quote
> But when the OnFilterRecord event
>occurs, the lookup field has not got its value yet (it has always a value of
>ASCII(1)). It seems that the lookup field get its value after the
>OnFilterRecord event. How can I filter this field?

You can not use the lookup for the value.  You need to use a separate Ttable and
Locate the value you want to find.  Then filter on the field in that located
record.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Lookup field and filters


Hi Antonio!

On Wed, 3 Jan 2001 09:43:50 +0100, "Antonio Revuelta"

Quote
<revue...@www.agbar.es> wrote:
>I have a Table (Table A) component with a lookup field obtained from another
>table component. I have set the Filtered property of Table A to true and
>written its OnFilterRecord event handler. But when the OnFilterRecord event
>occurs, the lookup field has not got its value yet (it has always a value of
>ASCII(1)). It seems that the lookup field get its value after the
>OnFilterRecord event. How can I filter this field?

in OnFilterRecord event of Table A fetch values for lookup field
manualy using TableB.Lookup(...) and examine those values. This is
becose filtering is done independently of lookup & calculated fields
population. Here is some code that might help...

var
        lData: variant;

      lData := cdsTapeLang.Lookup('TapeID;LangID',
        VarArrayOf([FTapeID, FLangID]),
        'Country;Place;Subject;Description;Note');

      if VarType(lData) = (varArray or varVariant) then
        begin
          cdsTapeCountry.AsVariant := lData[0];
          cdsTapePlace.AsVariant := lData[1];
          cdsTapeSubject.AsVariant := lData[2];
          cdsTapeDescription.AsVariant := lData[3];
          cdsTapeNote.AsVariant := lData[4];
        end;

Other Threads