Board index » delphi » Database filter doesn't seem to work

Database filter doesn't seem to work

I have been having a problem with filters on a Paradox databse.
The databse was set up using the Database Desktop. It can be accessed
without a problem in my project but I can't seem to get a filter set
properly.

Unfortunately, I am in the middle of a reinstall of my system so I can't
get the source code but...

The field I am trying to filter on is called Name. The value for the
filter is selected at runtime from a DBGrid component and moved into an
Edit component called Edit1. I have used the example in the help files:
Dataset1.Filter := '''State'' = ' + Edit1.Text;    DataSet1 being
replaced with Table1 and/or Datasource1.dataset1. State is replaced with
Name.
The result I always get is an error indicating that the field "xxxxxx"
cannot be found. xxxxx is whatever is contained in Edit1.Text.

For example: the user selects the name "Coleen" from the grid. "Coleen"
is saved in Edit1. I then set the filter using "Table1.Filter :=
'''Name'' = ' + Edit1.Text;". Past this step I get the error stating
that "the field Coleen cannot be found". Filtering has been enabled. I
tried both with the properties box in the IDE and by putting in the
code.

I have also tried using: "Table1.Filter := 'Name = ' + Edit1.Text;". I
get the same results.

Any ideas?

Much appreciated......

 

Re:Database filter doesn't seem to work


On Wed, 23 Jun 1999 07:01:40 -0400, Terry Gaudet <tgau...@home.com>
wrote:

Quote
>I have also tried using: "Table1.Filter := 'Name = ' + Edit1.Text;". I
>get the same results.

Try:
    Table1.Filter := 'Name = ' + QuotedStr(Edit1.Text);

Jan

Re:Database filter doesn't seem to work


Quote
> I have also tried using: "Table1.Filter := 'Name = ' + Edit1.Text;". I
> get the same results.

Try

Table1.Filter := 'Name = ''+Edit1.Text+''';

So the string contains eg.:   Name = 'Coleen'

Simon

Re:Database filter doesn't seem to work


Literals must be in quotes. Try QuotedStr(Edit1.Text).

Bill

--

Bill Todd - TeamB
(TeamB cannot respond to email questions. To contact me
 for any other reason remove nospam from my address.)

Other Threads