Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# query criteria determined by IIf statement

Posted on 2007-11-15
Medium Priority
561 Views
Hello ~

I'd like to incorporate the following IIf statement into a query criteria:

IIf([forms]![frmMain]![ckConsent]=1,-1)

Implied IF the control value is NOT 1, display all records.
Alternatively, IF the control value is NOT 1, display records w/ -1 or 0 in the field.

Tried:
IF the control value is NOT 1, no records are displayed - as written
IIf([forms]![frmMain]![ckConsent]=1,-1, -1 Or 0)
Does not work.

0
Question by:Chi Is Current
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2
• 2

LVL 16

Accepted Solution

Rick_Rickards earned 2000 total points
ID: 20296299
If I understand what you're trying to do the following in the critera I think will render the result you're after...

<> IIf([forms]![frmMain]![ckConsent],0, 1)

If chkConcent is true then all values with true will be displayed...
If chkConcent is false than all values true and false will be displayed because a boolean field will only contain -1 and  0 for values thus both are <> (not equal to) 1.  In the inverse condition we are saying not equal to 0 which would leave us with only values that are -1.

0

LVL 2

Author Comment

ID: 20296365
Cee Wah!  That's exactly it.

Extra thanks for lightning fast response time and the mind reading. (I think I did not articulate that question very well.)

Interesting the way that works.

Thank you, Jacob
0

LVL 2

Author Closing Comment

ID: 31409500
Exceptional solution & explanation!!!!!!  Blindingly FAST!!!
0

LVL 16

Expert Comment

ID: 20296403
You're most welcome!!!

Rick
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
###### Suggested Courses
Course of the Month11 days, 2 hours left to enroll