Double filter for subform

  • Thread starter Thread starter Darkside
  • Start date Start date
D

Darkside

How do I filter a subform on filtered data. Example: currently I filter the
subform based on the data column,which works. However, what I really want is
to find all of the data #'s with the same info #.

Would someone please help me with this issue?

Data Info
12 8989
23 020
34 8989
45 234
23 8989

Filtered:
Data Info
12 8989
34 8989
23 8989


Here is the code I use to find the Data # only.
ElseIf cboFilter = "NCC" Then
strWhere = strWhere & "([STOCK #] Like """ & txtFilterMain & """) AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else strWhere = Left$(strWhere, lngLen)
Me![tbl_ERX SubForm].Form.Filter = strWhere
Me![tbl_ERX SubForm].Form.FilterOn = True

End If
 
Darkside,

There is no need to use "Like" unless you want to be able to enter "89" into
the txtFilterMain and have it return records for:

89
891
8989

And if that is what you want to do, then you need to add some wildcard
characters to strWhere; similar to:

strWhere = strWhere & "([Stock #] Like '*" & me.txtFilterMain & "*') AND "

This particular code would find "89" anywhere in the Stock# field, If you
only want those that start with "89" you would use:

strWhere = strWhere & "([Stock #] Like '" & me.txtFilterMain & "*') AND "

Other than that, it looks like your code should work.
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
Back
Top