With e.form
Dim sql,str1,kz As String
kz = "ComboBox3,ComboBox4,ComboBox1,TextBox2,DateTimePicker3,DateTimePicker4"
str1 = "审核状态='@$0',部门= '@$1',岗位= '@$2',责任人= '@$3',日期 >= #@$4#,日期 <= #@$5#"
Dim i As Integer
For Each k As String In kz.split(",")
If .Controls(k).Value IsNot Nothing Then
If i=0 And .Controls("CheckBox2").Checked Then
sql = sql & " AND " & str1.split(",")(i).Replace("='@$" & i," like '%" & .Controls(k).Value & "%")
Else
sql = sql & " AND " & str1.split(",")(i).Replace("@$" & i,.Controls(k).Value)
End If
End If
i += 1
Next
If sql > "" Then
Tables("现场检查").Filter = sql
End If
End With
出错说:
此主题相关图片如下:未命名.jpg

还有 上面代码中 i += 1 是原版华海仓库的 是错的 还是什么? 我觉得应该是i = i+1啊!
[此贴子已经被作者于2011-12-17 22:24:13编辑过]