Double filter for subform

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
 
D

Dale Fye

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top