我想从主窗体上的未绑定文本框中搜索子窗体的多个字段,但它似乎没有过滤任何内容。也没有出现错误消息。我的代码是:
Private Sub btnSearch2_Click()
Dim strfilter As String
If Me.GlobalSearch.Value <> "" Then
Me.FilterOn = False
Me.GlobalSearch.SetFocus
Else
strfilter = "(HarvestId LIKE '*" & Me.GlobalSearch.Value & "*' OR "
strfilter = strfilter & "AssignedTo LIKE '*" & Me.GlobalSearch.Value & "*' OR "
strfilter = strfilter & "HarvestStatus LIKE '*" & Me.GlobalSearch.Value & "*')"
End If
'If strfilter <> "" Then
'Me.Filter = strfilter
'Me.FilterOn = True
'Else
'Me.FilterOn = False
'End If
End Sub
其中GlobalSearch是搜索文本框,HarvestId,AssignedTo和HarvestStatus是我要在子窗体中搜索的字段。为什么代码不起作用? 谢谢 玛丽
答案 0 :(得分:0)
假设您的子表单被称为HarvestSub
,请将注释后的代码替换为:
If strfilter <> "" Then
Me.HarvestSub.Form.Filter = strfilter
Me.HarvestSub.Form.FilterOn = True
Else
Me.HarvestSub.Form.FilterOn = False
End If