vb+access调程序时,总是出现“标准表达式数据类型不匹配”的错误,不知是什么原因?
PrivateSubCommand1_Click()'OnErrorGoTocmderrorDimfind_date1AsStringDimfind_date2AsStr...
Private Sub Command1_Click()
'On Error GoTo cmderror
Dim find_date1 As String
Dim find_date2 As String
If Option1.Value = True Then
sqlfind = "select * from 图书资料 where 编号 between '" & _
Combo1(0).Text & "'" & " and " & "'" & Combo1(1).Text & "'"
End If
If Option2.Value = True Then
find_date1 = Comboy(0).Text & "-" & _
Combom(0).Text & "-" & Combod(0).Text
find_date2 = Comboy(1).Text & "-" & _
Combom(1).Text & "-" & Combod(1).Text
sqlfind = "select * from 图书资料 where 购买日期 between '" & find_date1 & "'" & "and" & "'" & find_date2 & "'"
End If
rs_data1.Open sqlfind, conn, adOpenKeyset, adLockPessimistic
frmdatamanage.displaygrid1
Unload Me
'cmderror:
'If Err.Number <> 0 Then
'MsgBox "请输入正确的查询条件!", vbOKOnly + vbExclamation, "警告"
'End If
End Sub
调试的时候就停在rs_data1.Open sqlfind, conn, adOpenKeyset, adLockPessimistic这句上 展开
'On Error GoTo cmderror
Dim find_date1 As String
Dim find_date2 As String
If Option1.Value = True Then
sqlfind = "select * from 图书资料 where 编号 between '" & _
Combo1(0).Text & "'" & " and " & "'" & Combo1(1).Text & "'"
End If
If Option2.Value = True Then
find_date1 = Comboy(0).Text & "-" & _
Combom(0).Text & "-" & Combod(0).Text
find_date2 = Comboy(1).Text & "-" & _
Combom(1).Text & "-" & Combod(1).Text
sqlfind = "select * from 图书资料 where 购买日期 between '" & find_date1 & "'" & "and" & "'" & find_date2 & "'"
End If
rs_data1.Open sqlfind, conn, adOpenKeyset, adLockPessimistic
frmdatamanage.displaygrid1
Unload Me
'cmderror:
'If Err.Number <> 0 Then
'MsgBox "请输入正确的查询条件!", vbOKOnly + vbExclamation, "警告"
'End If
End Sub
调试的时候就停在rs_data1.Open sqlfind, conn, adOpenKeyset, adLockPessimistic这句上 展开
1个回答
展开全部
sqlfind = "select * from 图书资料 where 购买日期 between '" & find_date1 & "'" & "and" & "'" &
日期赋值错误. #' & find_date1 & '# 在Access数据库中采用#符号把日期括起来
日期赋值错误. #' & find_date1 & '# 在Access数据库中采用#符号把日期括起来
更多追问追答
追问
谢谢!这下能输出了,可是输出结果不是按查询条件输出的。
追答
不是按照查询条件输出的.那就是查询的错误设定了.
BETWEEN 操作符在 WHERE 子句中使用,会选取介于两个值之间的数据范围。这些值可以是数值、文本或者日期
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询