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#'
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#'
你在之前debug下这3个变量
HOW TO DEBUG 我是新手 我在测试的时候 输入了个时间 数据库里也能看到 输入的3个年月日的字段
另外,你那3个变量赋值语句怎么的?应该多放点代码出来看看
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 是一个文本型字段 输入日期的
你用日期时间型字段来作 Expire,不要用字符型。"select * from Purchase where Expire < #" & Format(Now, "yyyy-mm-dd")) & "#"
你的查询语句写得有问题,请一定按照下面查询语句写入测试。
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