select 语法错误
请问务位大侠,错在哪里,多谢!
Private Sub selcmd1_Click()
Dim str As String
str = ""
If Trim(Text1.Text) <> "" Then
If str = "" Then
str = "姓名='" + Trim(Text1.Text) + "'"
Else
str = str + "and 姓名='" + Trim(Text1.Text) + "'"
End If
End If
If Trim(DataCombo1.Text) <> "" Then
If str = "" Then
str = "所属系部='" + Trim(DataCombo1.Text) + "'"
Else
str = str + "and 所属系部='" + Trim(DataCombo1.Text) + "'"
End If
End If
If Trim(DataCombo2.Text) <> "" Then
If str = "" Then
str = "职称='" + Trim(DataCombo2.Text) + "'"
Else
str = str + "and 职称='" + Trim(DataCombo2.Text) + "'"
End If
End If
If Trim(DataCombo3.Text) <> "" Then
If str = "" Then
str = "课题级别='" + Trim(DataCombo3.Text) + "'"
Else
str = str + "and 课题级别='" + Trim(DataCombo3.Text) + "'"
End If
End If
If Trim(Text2.Text) <> "" Then
If str = "" Then
str = "课题题目='" + Trim(Text2.Text) + "'"
Else
str = str + "and 课题题目='" + Trim(Text2.Text) + "'"
End If
End If
If Trim(DataCombo3.Text) <> "" Then
If str = "" Then
str = "奖励级别='" + Trim(DataCombo3.Text) + "'"
Else
str = str + "and 奖励级别='" + Trim(DataCombo3.Text) + "'"
End If
End If
If str <> "" Then
If DTPicker1.Value = DTPicker2.Value Then
Adodc1.RecordSource = "select * from jiaoyanjiaogaiketi where " + str
Adodc1.Refresh
Else
Adodc1.RecordSource = "select * from jiaoyanjiaogaiketi where " + str + "and 开题时间 between '" & CDate(DTPicker1.Value) & "'and '" & CDate(DTPicker2.Value) & "'"
Adodc1.Refresh
End If
Else
Adodc1.RecordSource = "select * from jiaoyanjiaogaiketi"
Adodc1.Refresh
End If
recs = Adodc1.Recordset.RecordCount
If recs = 0 Then
MsgBox "没有任何满足条件的记录", vbOKOnly, "信息提示"
End If
Call encomm
End Sub