vb查询access时总提示操作符丢失等错误,求指导,谢谢
查询代码如下:Private Sub Command7_Click()
'模糊查找操作
ser = " where 1=1"
If Option1.Value = True Then
ser = ser & " and 日期 between " & Chr(35) & DTPicker3.Value & Chr(35) & " and " & Chr(35) & DTPicker4.Value & Chr(35) & ""
End If
'如果加工类别被选中
If Check1.Value = 1 Then
ser = ser & " and 加工类别 like '%" & Trim(Combo9.Text) & "%'"
End If
'如果G编号被选中
If Check2.Value = 1 Then
ser = ser & " and G编号 like '%" & Trim(Text20.Text) & "%'"
End If
'如果F编号被选中
If Check3.Value = 1 Then
ser = ser & " and F编号 like '%" & Trim(Text21.Text) & "%'"
End If
'如果工程名称被选中
If Check4.Value = 1 Then
ser = ser & " and 工程名称 like'%" & Trim(Text22.Text) & "%'"
End If
'如果工令号被选中
If Check5.Value = 1 Then
ser = ser & " and 工令号 like'%" & Trim(Text23.Text) & "%'"
End If
'如果备注被选中
If Check6.Value = 1 Then
ser = ser & " and 备注 like'%" & Trim(Text24.Text) & "%'"
End If
'如果状态被选中
If Check7.Value = 1 Then
ser = ser & " and 状态 like'%" & Trim(Combo7.Text) & "%'"
End If
'如果发运被选中
If Check8.Value = 1 Then
ser = ser & " and 发运 like'%" & Trim(Combo8.Text) & "%'"
End If
Adodc2.RecordSource = "select * from 计划内 where" & ser & "order by val(序号)"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
Adodc3.RecordSource = "select sum(数量)as 数量,sum(已完成)as 已完成,sum(未完成)as 未完成 from 计划内 where " & ser
Adodc3.Refresh
Label34.Caption = "共查询出" & Space(1) & Adodc2.Recordset.RecordCount & Space(1) & "条结果" & Space(2) & _
"合计数量:" & Space(1) & Adodc3.Recordset.Fields(0) & Space(1) & "根" & Space(2) & _
"合计已完成:" & Space(1) & Format(Adodc3.Recordset.Fields(1), "0") & Space(1) & "根" & Space(2) & _
"合计未完成:" & Space(1) & Format(Adodc3.Recordset.Fields(2), "0") & Space(1) & "根"
Else
Label34.Caption = "共查询出" & Space(1) & 0 & Space(1) & "条结果" & Space(2) & _
"合计数量:" & Space(1) & 0 & Space(1) & Space(1) & "根" & Space(2) & _
"合计已完成:" & Space(1) & 0 & Space(1) & "根" & Space(2) & _
"合计未完成:" & Space(1) & 0 & Space(1) & "根"
End If
End Sub