This article was previously published under Q208970
Moderate: Requires basic macro, coding, and interoperability skills.
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
strFilter = BuildCriteria("Product Name", adBSTR, strInput)
strFilter = BuildCriteria("[Product Name]", adBSTR, strInput)
'******************************************************************
' This procedure opens a form and applies a filter.
'******************************************************************
Sub SetFilter()
Dim frm As Form, strMsg As String
Dim strInput As String, strFilter As String
' Open Products form in Form view.
DoCmd.OpenForm "Products"
' Return Form object variable pointing to Products form.
Set frm = Forms!Products
strMsg = "Enter one or more letters of product name " & _
"followed by an asterisk."
' Prompt user for input.
strInput = InputBox(strMsg)
' Build criteria string.
strFilter = BuildCriteria("Product Name", adBSTR, strInput)
' Set Filter property to apply filter.
frm.Filter = strFilter
' Set FilterOn property; form now shows filtered records.
frm.FilterOn = True
End Sub
SetFilter
Keywords: KB208970, kbprb, kberrmsg