Combine the 2 into a string, like this:
Dim strWhere As String
strWhere = "([Cl] = """ & Me.CL & """) AND ([Set] = """ & Me.ID & """)"
'Debug.Print strWhere
With Forms![COA]
If .Dirty Then .Dirty = False
.Filter = strWhere
.FilterOn = True
End With
Notes:
====
1. If these fields are Number type (not Text type) when you open the table
in design view, omit the extra quotes. For an explanation of the quotes,
see:
http://allenbrowne.com/casu-17.html
2. Hopefully CL and ID are *unbound* controls, so you're not trying to use
them both for saving the value into the current record and also for setting
the filter on the form.
3. SET is a reserved word, so could cause you grief in some contexts. For a
list of the words to avoid when creating fields, see:
http://allenbrowne.com/AppIssueBadWord.html#S
4. If you have lots of these to combine, you might like to download the
sample application in this article, pull it apart, and see how it builds the
filter string:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Faraz A. Qureshi said:
How can I join two .Filter statements so as to apply multiple criteria.
Please rewrite the following code in this regard, because it results into
a
filter being applied first on Cl = CL basis, then CHANGES the same to Set
=
ID basis, whereas, I require both conditions to be met.
Forms![COA].Filter = "[Cl] = " & """" & Me.CL & """"
Forms![COA].Filter = "[Set] = " & """" & Me.ID & """"
.