My Assistant
![]() ![]() |
|
|
Sep 29 2011, 03:17 PM
Post
#1
|
|
|
UtterAccess Member Posts: 24 |
I am trying to use a check box from a form to filter a query. If the box is checked I want all records like "sm*" otherwise I want all records not like "sm*"
As a test I have been trying IIf(1=1,"like & '*'") in the Criteria box, I can't seem to get any records to display. I can't figure out how to pass the like "*" from the IIF statement. I also tried IIf(1=1,"like *") IIf(1=1,"like '*'") Thanks. |
|
|
|
Sep 29 2011, 03:22 PM
Post
#2
|
|
|
Access Wiki and Forums Moderator Posts: 47,918 From: SoCal, USA |
Hi,
(IMG:style_emoticons/default/welcome2UA.gif) Try something like: Like "sm*" And Forms!FormName.CheckboxName = True Not Like "sm*" And Forms!FormName.CheckboxName = False Note: Enter each line into separate criteria rows under the column/field you want to filter. (untested) Hope that helps... |
|
|
|
Sep 29 2011, 03:49 PM
Post
#3
|
|
|
UtterAccess Member Posts: 24 |
The core concept worked. I had to change things to fit what I have but it worked.
Here is my final code. Like "SM*" And [Forms]![Servicetracker]![Service-C]="-1" Or Not Like "SM*" And [Forms]![Servicetracker]![Other-C]="-1" Service-C is one check box and Other-C is another. when none are checked no results, if 1 checked I get either like or not like, and if both checked I get everything. |
|
|
|
Sep 29 2011, 03:56 PM
Post
#4
|
|
|
Access Wiki and Forums Moderator Posts: 47,918 From: SoCal, USA |
Hi,
Glad to hear you got it to work. Just a couple of comments: 1. Be careful when using multiple logical operators in your criteria. You have to be aware of their precedence order so you don't get unexpected results. 2. If [Service-C] is a Checkbox (Yes/No) type, I don't think you're supposed to enclose "-1" in quotes. Good luck with your project. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th May 2013 - 04:44 PM |