Dim Filter ,colname ,txt As String '定义变量
colname =e.Form.Controls("ComboBox1").Value '定义组合框的值
txt = e.Form.Controls("TextBox1").Value '定义文本框的值
If colname Is Nothing Then '如果组合框的值为空
Return '返回
End If
For Each dc As Col In Tables("表A").Cols '遍历表的所有列
If dc.DataCol.IsDate OrElse dc.DataCol.IsBoolean OrElse dc.DataCol.IsNumeric Then '如果是时间列,逻辑列,数值列
Continue For '排除
End If
If dc.Name = colname Then '如果列名和组合框的值相符
If Filter > "" Then
Filter = Filter & " Or "
End If
Filter = Filter & "[" & dc.Name & "] Like '*" & txt & "*'" '定义筛选字符串
End If '根据控件值迷糊筛选
Next
Tables("表A").Filter = Filter '将数据筛选出来
自己改改!我测试好上来的.