Like *bbc* criteria

KyleT

New member
Local time
Yesterday, 17:16
Joined
Jan 13, 2007
Messages
5
Hello, I understand that when using the "Like" command in a query - you should make use of wildcards to obtain the required data, but what happens if the required data is user inputted?

ie I currently use in the criteria box....

forms!frmselectclient!txtsearch.text

but I effectively want...

Like forms!fromselectclient!txtsearch.text, however I can't get this to work.

I'm guessing that this is something simple. Any ideas?
 
Code:
Like "*" & TextBox & "*"
 
SJ McAbney said:
Code:
Like "*" & TextBox & "*"
Legend! Cheers
 
This 95% answers the question that I have, but when there is nothing in the text box it brings back everything, when I would prefer it to bring back nothing.

Can anyone help?
 
how about have the search field and run qry after update
and remove the field fromth e tab order so someone has to point their mouse to it to access it ???
thinking out loud here !
 
the thought that I had was to incorporate and IIF function into it. As it stands the criterea looks something like this

Like "*" & [S2 Concatenated]![Concatenated List] & "*"

But if [S2 Concatenated]![Concatenated List] is "" it brings back everything.

I thought that I could do an IIF function but it didnt really work too well (well not at all)

IIf([S2 Concatenated]![Concatenated List])="",[S2 Concatenated]![Concatenated List], Like "*" & [S2 Concatenated]![Concatenated List] & "*")
 
In addition to having a closing paratheses too early, you are searching for an empty string, which is different than a NULL. Convert the NULL to an empty string first, and you should be okay.

IIf(Nz([S2 Concatenated]![Concatenated List],"")="",[S2 Concatenated]![Concatenated List], Like "*" & [S2 Concatenated]![Concatenated List] & "*")
 

Users who are viewing this thread

Back
Top Bottom