将查询文本框的名称与列名称保持一致。
Dim flt As String
For Each c As Col In Tables("全部编制").Cols
For Each ctl As WinForm.Control In e.Form.Controls
If c.Name = ctl.Name AndAlso e.Form.Controls(ctl.Name).Text > "" Then
flt + = " And " & c.Name & " Like '%" & e.Form.Controls(ctl.Name).Text & "%'"
End If
Next
Next
Tables("全部编制").Filter = IIF(flt > "",flt.SubString(5),flt)
[此贴子已经被作者于2014-2-22 18:13:28编辑过]