根据网有要求,由于子窗体字段较多,所以通过遍历子窗体所有控件,然后进行模糊查询。下载附件
Dim strWhere As String
Dim ctl As Control
Dim ctlname As String
strWhere = Trim$(Me.Text4.Text)
For Each ctl In Me.物资库存_子窗体.Form.Controls
If TypeOf ctl Is TextBox Then
ctlname = ctlname & "[" & ctl.Name & "] & "
End If
Next
ctlname = Left(ctlname, Len(ctlname) - 3)
strWhere = "" & ctlname & " like '*" & strWhere & "*'"
Me.物资库存_子窗体.Form.Filter = strWhere
'应用筛选
Me.物资库存_子窗体.Form.FilterOn = True