Solved

Access Query with Iif

Posted on 2014-12-13
2
196 Views
Last Modified: 2014-12-13
Hi.  I have a user form for folks to run some data-defined reports.  It has a checkbox, asking if they also want to filter by contactID.  (Number) If checked, then they can choose the contact from a list, and the contacts ID is placed in a field called "MyContact".  If the FilterByContact is NOT checked, however, I would like the query to show ALL contacts just filter on the dates.  But the contact criteria is not working and I don't know how to tell it to show ALL contacts when the box is NOT checked.  Any help appreciate.

Here is the Query Criteria I have in the ContactID field:
IIf([Forms]![frmDateInputForm]![FilterByContact]=True,[forms]![frmDateInputForm]![MyContact],*)

It all works fine except when needing to show ALL.

Thanks,
0
Comment
Question by:Not2ruthless
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40498200
try this

IIf([Forms]![frmDateInputForm]![FilterByContact]=True,[forms]![frmDateInputForm]![MyContact],[ContactID])
0
 

Author Closing Comment

by:Not2ruthless
ID: 40498215
Thanks SO much!
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question