Board index » delphi » How to filter a Lookup directly without filtering the Table

How to filter a Lookup directly without filtering the Table

Hi all
My problem is I need to filter the data displayed in a DBlookup without
using a table for the filtering.
For example.
A database table with several fields, 2 called "KeyWord", "TableName". In a
particular entry the keyword field may be = to "Maintenance Type", and the
field TableName =  "Planned Work" however scattered throughout the table
would be various entrees with the "KeyWord" Maintenance type and Table name
= to whatever.
Normally I would use a table filtered for the KeyWord =  "Maintenance Type"
then the Lookup pointing to the filtered table and only the values with
TableNames with Keyword = Maint..Type displayed in the lookup.

The trouble with the above approach is a table is needed for every different
Keyword in the Table and in this particular table there are about 40! Is
there a way to filter by only using the Lookup.
Thanks TW

 

Re:How to filter a Lookup directly without filtering the Table


Don't forget that you can use the "onfilterrecord" event to code exactly the
filter logic you want, in good old Pascal. If you need to pass parameters
between a control and the onfilter event (say, a series of partial keys
entered by the user in a tedit), simply put the required variables in the
private section of your form. If it can't be coded in Pascal, it probably
should not be attempted.

Robert

Quote
"tw" <tonyw...@primus.com> wrote in message

news:3997d7c9@news.iprimus.com.au...
Quote
> Hi all
> My problem is I need to filter the data displayed in a DBlookup without
> using a table for the filtering.
> For example.
> A database table with several fields, 2 called "KeyWord", "TableName". In
a
> particular entry the keyword field may be = to "Maintenance Type", and the
> field TableName =  "Planned Work" however scattered throughout the table
> would be various entrees with the "KeyWord" Maintenance type and Table
name
> = to whatever.
> Normally I would use a table filtered for the KeyWord =  "Maintenance
Type"
> then the Lookup pointing to the filtered table and only the values with
> TableNames with Keyword = Maint..Type displayed in the lookup.

> The trouble with the above approach is a table is needed for every
different
> Keyword in the Table and in this particular table there are about 40! Is
> there a way to filter by only using the Lookup.
> Thanks TW

Re:How to filter a Lookup directly without filtering the Table


Quote
"tw" <tonyw...@primus.com> wrote in message

news:3997d7c9@news.iprimus.com.au...

Quote
> Hi all
> My problem is I need to filter the data displayed in a DBlookup without
> using a table for the filtering.
> For example.
> A database table with several fields, 2 called "KeyWord", "TableName". In
a
> particular entry the keyword field may be = to "Maintenance Type", and the
> field TableName =  "Planned Work" however scattered throughout the table
> would be various entrees with the "KeyWord" Maintenance type and Table
name
> = to whatever.
> Normally I would use a table filtered for the KeyWord =  "Maintenance
Type"
> then the Lookup pointing to the filtered table and only the values with
> TableNames with Keyword = Maint..Type displayed in the lookup.

> The trouble with the above approach is a table is needed for every
different
> Keyword in the Table and in this particular table there are about 40! Is
> there a way to filter by only using the Lookup.
> Thanks TW

I'm not entirely clear on why you believe you need 40 different tables. Is
it that you have 40 different lookup combos on the same form? If so you
don't have many other options. OTH if its just a case of changing the filter
at run-time simply do something like
    aTable.Filtered := False;
    aTable.Refresh;    // if multi-user
    aTable.Filter := '[KeyWord] = "Maintenance Type"'; // whatever
    aTable.Filtered := True;

Other Threads