多条件查询的问题
我的语句是:Private Sub cmd_ok_Click()
Dim sql As String '声明变量,用来保存SQL语句字符串
sql = "select * from AdviceListView where roomcode=2000 " & _
" and sendopecode>0 " & _
" and exectime>'" & Trim(DTPicker1.Value) & "' " & _
" and exectime<'" & Trim(DTPicker2.Value) & "' " & _
" and offcode= " & DataCombo1.BoundText & _
" and patname like'" & Text2.Text & "%" & "' " & _
" and medname like'" & Txtmed.Text & "%" & "' " & _
" order by intime desc"
当选定时间时,运行不可以,当选offcide加时间,或offcode加medname加时间都可行,但是选时间加patname或时间加medname运行时出现提示“在关键字and附近有语法错误。我如果不先时间,其它条件同时都可运行。
我查不出,请各位抽出时间帮我看一下。