查日期型要注意以下几点:
日期的格式建议使用format;最好用between来查找一定的范围,因为你查"2002.11.19",其实你查的是"2002.11.19 00:00:00"。

解决方案 »

  1.   

    查询ACCESS数据库应使用:
        data between #2002-10-01# and #2002-10-25#
    查询SQL数据库应使用:
        data between '2002-10-01' and '2002-10-25'
      

  2.   

    我的源代码是这样的:
             For i = 0 To 14
             If Combo7(i).Text <> "" And Text3(i).Text <> "" Then
                str = str + " " + Label18(i).Caption
                str = str + " " + Combo7(i).Text
                str = str + " " + "( '*" & Trim(Text3(i).Text) & "*')"
                str = str + " " + Combo6(i).Text
             End If
            
             If RS.EOF Then
                MsgBox ("无所需查找的资料")
                Exit Sub
            End If
       
            Next
               str = Replace(str, "=", "LIKE")
               str = Replace(str, "并且", "and")
               str = Replace(str, "或者", "or")
          
               RS.Filter = str
            
               Label7.Caption = RS.RecordCount
    如果在Text3中输入日期型变量,就不行了!如何既能够用SQL来查字符型变量,又能够查日期型变量?这可能吗?请教!
      

  3.   

    如何既能够用SQL来查字符型变量,又能够查日期型变量?这可能吗?请教!
    不可能,你把下面的代码:
    str = str + " " + "( '*" & Trim(Text3(i).Text) & "*')"
    改成:
    str = str + " " + "( '#" & format(Text3(i).Text,"m/d/yy") & "#')"
    试试.