开发者

How do I filter my DBGrid with 2 strings?

dm.atinlog.open;
     target :=  leftStr(postcode,4);
     dm.atinlog.filter   := 'postcode like ' + QuotedStr(target+'%') AND dm.atinlog.filter := 'autorisatie = '  + QuotedStr('klant');
     dm.atinlog.filtered := true;
     dbgrid1.visible := true;

This is my filter code, but this isn't working.

[DCC Error] 开发者_开发问答unPostcode.pas(95): E2010 Incompatible types: 'string' and 'procedure, untyped pointer or untyped parameter'

This error is given. What is the problem and what do I need to do to make it work? The string "klant" is taken from a database. It works apart from each other. however when using filter separate only the second filter works.

Please help, Thanks in advance

Jasper


Change the code into:

dm.atinlog.open;
target := leftStr(postcode,4);
dm.atinlog.filter := 'postcode like ' + QuotedStr(target+'%') 
                   + 'AND autorisatie = '+ QuotedStr('klant');
dm.atinlog.filtered := true;
dbgrid1.visible := true;


Johan already gave a good answer on how to fix your filter string. But I would like to point out that if at all possible you should be using an index and SetRange instead for optimal performance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜