cpclifford
New Member
- Joined
- Mar 9, 2011
- Messages
- 2
I have a form that allows users to enter search criteria in two item description boxes. One box is criteria to search for and include results while the other asks for criteria to exclude. Both of these boxes make use of wild cards "*" for user ease. For instance, I want a user to be able search for and include "battery" but exclude "aaa". Currently, the query works if the exclude box is populated. However, if it is not populated, access excludes all results because of the wildcard. Is there a way to tell access to search based on the include/ exclude criteria if populated but if the exclude criteria is blank (null) to search only on the include criteria? I have attempted to write an iif statement but cant seem to get it to work.
I am currently using the statement below, but it is returning zero results if the exclude box is left blank due to the wildcard. Wildcards are required.
Like ("*" & [Forms]![FRM_SEARCH_DB]![SEARCH_ITEM] & "*") And Not Like ("*" & [FORMS]![FRM_SEARCH_DB]![SEARCH_EXCLUDE] & "*")
Any suggestions? Thanks in advance, Chris
I am currently using the statement below, but it is returning zero results if the exclude box is left blank due to the wildcard. Wildcards are required.
Like ("*" & [Forms]![FRM_SEARCH_DB]![SEARCH_ITEM] & "*") And Not Like ("*" & [FORMS]![FRM_SEARCH_DB]![SEARCH_EXCLUDE] & "*")
Any suggestions? Thanks in advance, Chris