rsStudent.Filter = "id = '1' and (early = 1 or late = 1)" 
运行到此处居然会出错:
     变量或者类型不正确,或者不在可以接受的范围之内,要不就是与其他数据冲突。而把里面的括号去掉:
rsStudent.Filter = "id = '1' and early = 1 or late = 1"
程序运行则完全正常,但结果显然不是我想要的!!!! 我想要的是:筛选楚id=1的,并且只要early=1或者late=1满足其中一个条件即可的数据记录,请问应该怎样写啊??另外,奇怪的是把第一个sql语句放在sql server的查询分析器中查找却不会出错的!!若能解决万分感谢!!

解决方案 »

  1.   

    WHERE ((交存档案.启用日期 Is Null Or 交存档案.启用日期> convert(datetime,'" & Format(rq2, "mm-dd-yyyy") & "',102)) AND (车辆基础档案.吨座位 Is Not Null) and (交存档案.交存日期<=convert(datetime,'" & Format(rq2, "mm-dd-yyyy") & "',102)))"我的程序这么写不出错。你按照上边的试试。
      

  2.   

    to  LCAAA(小小程序员):
       不行啊,还是一样出错!!
      

  3.   

    rsStudent.Filter = "id='1'"
    rsStudent.Filter = "early = 1 or late = 1"
      

  4.   

    或者
    rsStudent.Filter = "(id='1' and early=1) or (id='1' and late=1)"
      

  5.   

    摘自MSDN
    There is no precedence between AND and OR. Clauses can be grouped within parentheses. However, you cannot group clauses joined by an OR and then join the group to another clause with an AND, like this
    (LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'Instead, you would construct this filter as (LastName = 'Smith' AND FirstName = 'John') OR (LastName = 'Jones' AND FirstName = 'John')
      

  6.   

    zhenglc(絮絮) 
       你的方法也不行啊!! 这样过虑条件会被覆盖掉的,即以最后赋值的为准的,这样结果又不对了!!   难道这样的问题没人知道怎样解决??????
      

  7.   

    rsStudent.Filter = "early + late and 1id = '1' "
      

  8.   

    zhenglc(絮絮) 
    你回得好快,我先试试你的第二种方法....
      

  9.   

    用zhenglc(絮絮)的方法
    rsStudent.Filter = "(id='1' and early=1) or (id='1' and late=1)"
    可是可以的,但OR条件多时,就程序就变得很冗长了!!of123()
     方法没看懂,能否解释一下啊,谢了! 
      

  10.   

    试试这个,括上引号
    rsStudent.Filter = "id = '1' and (early = '1' or late = '1')" 
      

  11.   

    filter 不可以这样写:
    (a or b) and (c or d)
    a and (b or c)
    (a or b) and c但可以这样写:
    (a and b) or (c and d)
    a and b and c
    a or b or c
    (a and b) or c
    a or (b and c)
    所以改成这样:
    rsStudent.Filter = "(id = '1' and early = 1) or (id = '1' and late = 1)"
      

  12.   

    如果只是这个条件,并且late和early只能是0或1,of123()的语句是可行的,late+early实际上就是一个或运算。