开发者

How do I filter my DBGrid with 2 strings?

开发者 https://www.devze.com 2023-03-12 10:13 出处:网络
dm.atinlog.open; target :=leftStr(postcode,4); dm.atinlog.filter:= \'postcode like \' + QuotedStr(target+\'%\') AND dm.atinlog.filter := \'autorisatie = \'+ QuotedStr(\'klant\');
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

精彩评论

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