Two Fields from a form, same query filter

FelipeH

New member
Local time
Yesterday, 21:20
Joined
May 22, 2012
Messages
7
Hello, people. I'm designing a search form which triggers a query (nothing unusual).

I have a problem when I use two fields (a text box and a combo box) for the same filter. The user can choose to use the text box or the combo box.

The problem is when the query is triggered, the query simply does not filter. If I remove the or criterion (txEQUIPE) it works. Is there a way to do this?

cbEQUIPE is the combo box, txEQUIPE is the text box:

Code:
Like [Forms]![f-FILTRAGEM]![cbEQUIPE] & "*"
Like [Forms]![f-FILTRAGEM]![txEQUIPE] & "*"

I had already tried to find something like this and have failed. A screenshot is attached since I haven't made 10 posts, yet.
 

Attachments

  • Untitled.png
    Untitled.png
    5.3 KB · Views: 86
Hey guys, I have a second problem which I guess is related to the first one.

On the same criteria fields within the query design, I have to set different criterias for the same column using the * wildcard. The problem is that the query is not filtering, too. I guess I'd have to put this all on one statement only.

Code:
Like "*" & [Forms]![f-FILTRAGEM]![txEQUIPE]
Like "* " & [Forms]![f-FILTRAGEM]![txEQUIPE]
Like [Forms]![f-FILTRAGEM]![txEQUIPE] & "*"	
Like [Forms]![f-FILTRAGEM]![txEQUIPE] & " *"


Thanks in advance.
 
Hey, Folks.

I found the answer for the second problem, after reading this website:

tek-tips.com/viewthread.cfm?qid=1677704

It's simple, I condensed both statements in one line.

Like "*" & [Forms]![f-FILTRAGEM]![txEQUIPE] Or Like [Forms]![f-FILTRAGEM]![txEQUIPE] & "*"

For instance, if I have a table with records "John, Paul", "Paul, John", and "John", and my search term is "John", it will now return all three records, not only "John" as it was returning previously.

But, my first doubt's still alive. How can I tell my access' query to perform this filtering using Like statement whether from a text box (txEQUIPE) whether from a combo box (cbEQUIPE) while using wildcard search method?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom