Solved

Access Query with Iif

Posted on 2014-12-13
2
205 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
[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
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

729 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