我要用过滤器把FootLeg字段中值为大于P1小于P2的记录筛选出来该如何写,其中P1,P2为变量,由使用者自己输入
  table1.filter:=............
  table1.filtered:=true;
在线等!

解决方案 »

  1.   

    table1.filter:='FootLeg>p1 and FootLeg<p2'
      

  2.   

    这样写不对,P1,P2是变量
    并且这样不匹配,因为P1 P2是一个数,而FootLeg 是一个字段名
    所以这样写还是不能得到结果
      

  3.   

    如果FlootLeg字段是数值型:
    table1.filter:='FootLeg>'+p1+' and FootLeg<'+p2
    不知道你用户输入的p1,p2的结果是什么类型,如是数值型就得加函数转换一下,不然上面语句中会出现 字符串和数值相回的编译错误。如果是字符型
    table1.filter:='FootLeg>'''+p1+''' and FootLeg<'''+p2+''''
      

  4.   

    假如FootLeg是一个数值型变量的话,可以这样。table1.filter := 'footLeg>'+intToStr(p1).
    如果p1,p2是字符串的话还要保证p1,p2的值在table1.filter的字符串中用引号括起来。