We help IT Professionals succeed at work.

Filtering a table

Idiotboy asked
I need to filter a table so i can display the correct records.  The problem is that I have about 3 or 4 critera's to meet but I keep getting an error when trying to complile.
The code I am using
Tab is a variable defined before the filter is set.

tbapptsearch.Filter := 'chiropractor_id =' + inttostr(tab)
 and 'status = '  +  quotedstr('pending');
The error I get points to the 2nd +.
[Error] datamod2.pas(187): Operator not applicable to this operand type.

Now if I do it like this.
tbapptsearch.Filter := ('chiropractor_id =' + inttostr(tab))
 and ('status = '  +  quotedstr('pending'));
I get the same error but it points to the ;.

My usuall style of trial and error codeing is failing me at this point.
Watch Question

you left the AND operator outside the filter !!

tbapptsearch.Filter := 'chiropractor_id = ' + inttostr(tab) + ' and status = ' + quotedstr('pending');

I'd write it like this

tbapptsearch.Filter := Format('chiropractor_id = %d and status = %s', [tab, quotedstr('pending')]);


Thanks Lee,  worked like a charm.

If you have time could you explain how the %d and %s works in your example.  I think i know, but haven't had the time to experiment with it yet.
%d is a holder for Integer numbers
%s is for strings

look up the Format function

Explore More ContentExplore courses, solutions, and other research materials related to this topic.