Board index » delphi » Filter a table using AND or filtering 2 fields at onces

Filter a table using AND or filtering 2 fields at onces

Can I do a filter that works in 2 different fields at the same time?

 Table1.Filter := 'Field1 = ' + "Hello" AND 'Field2 =  ' + "Hi";

Or how can I use AND in filters?

 

Re:Filter a table using AND or filtering 2 fields at onces


Quote
{*word*73} wrote in message <3a524176_2@dnews>...
>Can I do a filter that works in 2 different fields at the same time?

> Table1.Filter := 'Field1 = ' + "Hello" AND 'Field2 =  ' + "Hi";

Yes, give it a try.

--
Happy New Millenium!
Wayne Niddery (WinWright Inc.)
RADBooks - http://members.home.net/wniddery/
"As someone who has worked both in private industry and in academia,
whenever I hear about academics wanting to teach ethics to people in
business, I want to puke." - Thomas Sowell

Re:Filter a table using AND or filtering 2 fields at onces


Can't make it work

  Here is my code:

     DataModule1.Table1.Filter :=
                            'Name =  ' + QuotedStr(Edit1.Text)
                           + 'AND'+ 'LastName =  ' + QuotedStr(Edit2.Text);
    DataModule1.Table1.Filtered := True;

   I got this error:  'Filter expression incorrectly teminated'

    Tank's for any help.

"Wayne Niddery (TeamB)" <winwri...@chaffhome.com> wrote in message
news:3a524e73$1_2@dnews...

Quote
> {*word*73} wrote in message <3a524176_2@dnews>...
> >Can I do a filter that works in 2 different fields at the same time?

> > Table1.Filter := 'Field1 = ' + "Hello" AND 'Field2 =  ' + "Hi";

> Yes, give it a try.

> --
> Happy New Millenium!
> Wayne Niddery (WinWright Inc.)
> RADBooks - http://members.home.net/wniddery/
> "As someone who has worked both in private industry and in academia,
> whenever I hear about academics wanting to teach ethics to people in
> business, I want to puke." - Thomas Sowell

Re:Filter a table using AND or filtering 2 fields at onces


Quote
On Tue, 2 Jan 2001 19:58:34 -0800, "{*word*73}" <nom...@mymail.com> wrote:
>     DataModule1.Table1.Filter :=
>                            'Name =  ' + QuotedStr(Edit1.Text)
>                           + 'AND'+ 'LastName =  ' + QuotedStr(Edit2.Text);

You need spaces around the AND.

HTH,

Jan

Re:Filter a table using AND or filtering 2 fields at onces


Quote
{*word*73} wrote in message <3a52a589_2@dnews>...

>     DataModule1.Table1.Filter :=
>                            'Name =  ' + QuotedStr(Edit1.Text)
>                           + 'AND'+ 'LastName =  ' +

QuotedStr(Edit2.Text);

                           + ' AND LastName =  ' +
QuotedStr(Edit2.Text);

Note the spaces I added around the word 'AND".

--
Happy New Millenium!
Wayne Niddery (WinWright Inc.)
RADBooks - http://members.home.net/wniddery/
"As someone who has worked both in private industry and in academia,
whenever I hear about academics wanting to teach ethics to people in
business, I want to puke." - Thomas Sowell

Other Threads