Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Filtering a TTable using Like

1,094 views
Skip to first unread message

Stefano

unread,
Mar 18, 1998, 3:00:00 AM3/18/98
to

Hi,

I have a Paradox table with 2 fields, both of type string.
The table looks something like this.

Code Detail
-------- ---------
1 Test
1 Cat
1 ATestB
1 TestC
2 Dog
2 Boat
2 Test
3 Frog

My problem occurs when I try to filter the tables using the filter property
of a TTable. I would like to filter on records that have any combination of
the word 'Test'

If I try to set the properties like this, either at design time or run-time:
Table1.Filtered := True;
Table1.Filter := 'Detail Like '%Test%';
I get an error, 'Filter Expression Incorrectly Terminated'

If the above filter worked the result would be:

Code Detail
-------- --------
1 Test
1 ATestB
1 TestC
2 Test

I would appreciate any help with this.
Thank's in advance.

--
Stefano
stef...@rainmaker.com.au.NOSPAM

Ross French

unread,
Mar 18, 1998, 3:00:00 AM3/18/98
to

I have never tried to do exactly what you are doing, but I did take a quick
look at the help file and here is a quote:

"To filter strings bases on partial comparisons, use an asterisk as a
wildcard. For example: State = 'M*' "

I am not sure that "%" works. Also, if you are going to assign the filter
at run time you have to make sure that the string is enclosed in quotes.

Look at your original post. The first problem I see is that there are
three quotes. At a minimum you would need to have at least four (which
would work if the field you are filtering is a number), but in this case,
you need to show that the field is a string and you need to use 6 quotes.
So I am pretty sure your filter line should read:
" Table1.Filter := 'Detail Like ''*Test*'''; "
Once again, I am not sure if the "*" will work on both sides, but you can
try it.

Good luck.

Stefano

unread,
Mar 19, 1998, 3:00:00 AM3/19/98
to

Hi Ross,

Thanks for your suggestion, however I have tried all of that before, without
any luck. I think to get to the solution I want, I will have to change
tactic and solve it a different way.

Regards,
Stefano


-------------------------


>I have never tried to do exactly what you are doing, but I did take a quick
>look at the help file and here is a quote:
>
>"To filter strings bases on partial comparisons, use an asterisk as a
>wildcard. For example: State = 'M*' "

-------------------------

David Ullrich

unread,
Mar 19, 1998, 3:00:00 AM3/19/98
to

Stefano wrote:
[...]

> If I try to set the properties like this, either at design time or run-time:
> Table1.Filtered := True;
> Table1.Filter := 'Detail Like '%Test%';
> I get an error, 'Filter Expression Incorrectly Terminated'

This is simply not valid syntax for a table's Filter property.
The syntax for filters is spelled out very explicitly in the printed
docs (as opposed to the online help, where all I see is a few examples).
There's no "Like" operator in TTable.Filter.

I imagine you could do something like this with a TQuery instead
(just a guess, I haven't got to TQuery yet). OR you could do it using
TTable.OnFilterRecord - this is much more flexible than TTable.Filter.
See the docs on OnFilterRecord - you'd want something like

Accept:= (Pos(FieldValues['Detail'], 'Test') > 0);

--
David Ullrich

sig.txt not found

Stefano

unread,
Mar 20, 1998, 3:00:00 AM3/20/98
to

Hi David,

Thanks for your suggestion. I tried it this morning and it worked like a
dream.

Stefano


David Ullrich wrote in message <351172...@math.okstate.edu>...

David Ullrich

unread,
Mar 21, 1998, 3:00:00 AM3/21/98
to

Stefano wrote:
>
> Hi David,
>
> Thanks for your suggestion. I tried it this morning and it worked like a
> dream.

Fabulous. I suspected OnFilterrecord would do what you wanted.
But you should note I'm just starting the database stuff: if I got
the code for accessing the field value right it was by accident,
and even if it's right there may well be a more rfficient method
of doing that.

> David Ullrich wrote in message <351172...@math.okstate.edu>...
>
> > I imagine you could do something like this with a TQuery instead
> >(just a guess, I haven't got to TQuery yet). OR you could do it using
> >TTable.OnFilterRecord - this is much more flexible than TTable.Filter.
> >See the docs on OnFilterRecord - you'd want something like
> >
> >Accept:= (Pos(FieldValues['Detail'], 'Test') > 0);
> >

--

sead....@gmail.com

unread,
Jan 2, 2015, 5:02:58 PM1/2/15
to
On Friday, March 20, 1998 9:00:00 AM UTC+1, Stefano wrote:
> Hi David,
>
> Thanks for your suggestion. I tried it this morning and it worked like a
> dream.
>
> Stefano
>
>
> David Ullrich wrote in message <351172...@math.okstate.edu>...
>
> > I imagine you could do something like this with a TQuery instead
> >(just a guess, I haven't got to TQuery yet). OR you could do it using
> >TTable.OnFilterRecord - this is much more flexible than TTable.Filter.
> >See the docs on OnFilterRecord - you'd want something like
> >
> >Accept:= (Pos(FieldValues['Detail'], 'Test') > 0);
> >

Hello Stefano I have same problem but I could figure out.Can you write your code how did you solve it.
I have exact same problem.
Thank you

sead....@gmail.com

unread,
Jan 3, 2015, 2:29:07 AM1/3/15
to
On Wednesday, March 18, 1998 9:00:00 AM UTC+1, Stefano wrote:
> Hi,
>
> I have a Paradox table with 2 fields, both of type string.
> The table looks something like this.
>
> Code Detail
> -------- ---------
> 1 Test
> 1 Cat
> 1 ATestB
> 1 TestC
> 2 Dog
> 2 Boat
> 2 Test
> 3 Frog
>
> My problem occurs when I try to filter the tables using the filter property
> of a TTable. I would like to filter on records that have any combination of
> the word 'Test'
>
> If I try to set the properties like this, either at design time or run-time:
> Table1.Filtered := True;
> Table1.Filter := 'Detail Like '%Test%';
> I get an error, 'Filter Expression Incorrectly Terminated'
>
> If the above filter worked the result would be:
>
> Code Detail
> -------- --------
> 1 Test
> 1 ATestB
> 1 TestC
> 2 Test
>
> I would appreciate any help with this.
> Thank's in advance.
>
> --
> Stefano
> stef...@rainmaker.com.au.NOSPAM

Hello Stefano I have same problem but I couldn't figure out.Can you write your code how did you solve it or send me on my email sead...@hotmail.com
0 new messages