strgood = "select * from Purchase where #" & (Format(Now, "yyyy-mm-dd")) & "# > #" & Val(Expire_Year) & " - " & Val(Expire_Month) & " - " & Val(Expire_Day) & "#"还是这条语句 查不出来到期货物 三个文本类型字段组成的日期错误提示为  语法错误 '#2011-3-15#'>'#0-0-0#'

解决方案 »

  1.   

    "select * from Purchase where #" & (Format(Now, "yyyy-mm-dd")) & "# > #" & Trim(Expire_Year) & " - " & Trim(Expire_Month) & " - " & Trim(Expire_Day) & "#"试试这个看怎么样?自己没测试
      

  2.   

    Expire_Year系列变量无值啊
    你在之前debug下这3个变量
      

  3.   

    我是为了查询过期产品这个功能 后来加了三个文本字段 表示时间年月日   现在就是这个问题 
    HOW TO DEBUG  我是新手 我在测试的时候 输入了个时间 数据库里也能看到 输入的3个年月日的字段
      

  4.   

    按照楼上吧 三个合成一个文本框去输入时间 Expire变量 还是0 咋回事~~
      

  5.   

    似乎你语法真的错误。你这个sql语句where后面应该是“字段名”“关系”“值”,比如有个InDate字段,应该这样:where InDate > '2011-03-15' 
    另外,你那3个变量赋值语句怎么的?应该多放点代码出来看看
      

  6.   

    用一个按钮去查询进货表中 过期的产品 然后再datagrid中显示出来 就要这个功能
    strgood = "select * from Purchase where #" & (Format(Now, "yyyy-mm-dd")) & "# > # " & CDate(Expire) & " #"
    rs_goods.Open strgood, conn, adOpenStatic, adLockOptimistic
    Adodc1.RecordSource = strgood
    Adodc1.Refresh
    Set DataGrid1.DataSource = Adodc1
    If rs_goods.RecordCount > 0 Then
    Beep
    MsgBox "Some products have expired,Please check it", vbOKOnly + vbInformation, "Warning"
    Else
    MsgBox "No product have expired", vbOKOnly + vbInformation, "Warning"
    End If
    rs_goods.Close
    End Sub
    刚才测试结果 没有成功 只是把进货表里全部数据显示了  expire 是一个文本型字段 输入日期的  
      

  7.   

    "select * from Purchase where Expire < #" & Format(Now, "yyyy-mm-dd")) & "#"试试这个
      

  8.   


    你用日期时间型字段来作 Expire,不要用字符型。"select * from Purchase where Expire < #" & Format(Now, "yyyy-mm-dd")) & "#"
      

  9.   


    你的查询语句写得有问题,请一定按照下面查询语句写入测试。
    Private Sub Command1_Click()
      strgood = "select * from Purchase where int(now)>CDate(Expire)"
    '  Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My Documents\db111.mdb;Persist Security Info=False"
      Adodc1.RecordSource = strgood
      Adodc1.Refresh
      Set DataGrid1.DataSource = Adodc1
      If Adodc1.Recordset.RecordCount > 0 Then
        Beep
        MsgBox "Some products have expired,Please check it", vbOKOnly + vbInformation, "Warning"
      Else
        MsgBox "No product have expired", vbOKOnly + vbInformation, "Warning"
      End IfEnd Sub