Filtering table already filtered .....

Filtering table already filtered .....

Post by Daniel » Sun, 31 Dec 1899 09:00:00



Hi ,
     j have one problem ......
J have one table with 5003 records and there is a button that open a filter
form.
In this form there are :
#1 TQuery                 (Query1)
#1 TDBGrid              (DBGrid1)
#1 TDataSource      (DataSource1)

DBGrid1 is linked to DataSource1 and DataSource1 is linked to Query1

Now j filter the table with the Query1.Sql and the line is :

Query1.SQL.Add('Select * FROM '+TT.TableName+' WHERE Brand' Like '
+QuotedStr(FilterEdit.Text));

Where :
TT.TableName is the table name (MyTable.DB)
Brand                is one record's field
FilterEdit           is the TEdit component (the value is 'band%')

When j run the query j will find about 1000 record ( given by
Qurey1.RecordCount ).
At this point j need to refilter the query ..... but how is possible ??????

If j try to do this

Query1.SQL.Add('Select * FROM Query1  WHERE Brand' Like '
+QuotedStr(FilterEdit.Text));

when j run the query j will get this error
File or directory does not exist :
C:\......\.....\Query1.DB
C:\.......\.....\Query1.DBF
C:\........\.....\Query1.TXT

What j can do to refilter this table ???

Thanks for your help

Bye

Daniele

 
 
 

Filtering table already filtered .....

Post by Yuri Levashk » Sun, 31 Dec 1899 09:00:00


Hi!
Quote:

> Where :
> TT.TableName is the table name (MyTable.DB)
> Brand                is one record's field
> FilterEdit           is the TEdit component (the value is 'band%')

> When j run the query j will find about 1000 record ( given by
> Qurey1.RecordCount ).
> At this point j need to refilter the query ..... but how is possible

??????
Just close and open your Query:
Query1.Close;
Query1.Open;
Quote:

> If j try to do this

> Query1.SQL.Add('Select * FROM Query1  WHERE Brand' Like '

                                                   ^^^^^ Only table name can
be here!
SQL doesn't know anything about TQuery Query1 and looks for table with name
query1!

Quote:> +QuotedStr(FilterEdit.Text));

> when j run the query j will get this error
> File or directory does not exist :
> C:\......\.....\Query1.DB
> C:\.......\.....\Query1.DBF
> C:\........\.....\Query1.TXT

--
Best Regards
Yuri S. Levashko, LANIT Inc.

 
 
 

Filtering table already filtered .....

Post by Steve Koters » Sun, 31 Dec 1899 09:00:00


[...]

Quote:>If j try to do this

>Query1.SQL.Add('Select * FROM Query1  WHERE Brand' Like '
>+QuotedStr(FilterEdit.Text));

>when j run the query j will get this error
>File or directory does not exist :
>C:\......\.....\Query1.DB
>C:\.......\.....\Query1.DBF
>C:\........\.....\Query1.TXT

>What j can do to refilter this table ???

That TQuery component Query1 is a Delphi object, existing only in the
Delphi application's memory space. SQL, OTOH, can only be executed against
persistent base tables. You cannot reference a TQuery or TTable in an SQL
statement as if it were a base table.

One option you have is to add the new criteria to the existing SQL
statement and execute it again.

Another option is to save the result set to a (local) base table using the
BDE API function DbiMakePermanent. Then, you can execute the second SELECT
statement against that new table.

If the original statement is executed against a local table (dBASE,
Paradox, FoxPro), you can use the local SQL equivalent of a VIEW. Save the
first statement to a text file (with a .SQL extension) and execute the
second statement against that file. This is more akin to the first choice,
above, as the first query ends up being executed again.

If the SQL is on an SQL database, you can use a VIEW based on the first
statement to derive the second result set.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski              "Health nuts are going to feel stupid someday,
Felton, CA                  lying in hospitals dying of nothing."
                                                              -- Redd Foxx

 
 
 

1. 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

2. Content type for MIME when using xp_sendmail

3. show members with empty measure values/filters on filters

4. Empty cube after process.

5. Row filters don't filter enough

6. Ontape

7. Problem with filters and join filters in merge replication

8. Amend table structure at publication database

9. To filter or not to filter???

10. How detect filter selected in filter axis?

11. Row Filter & Join Filter

12. Dynamic filter vs static filter...

13. Partial filter strings Filters ?