Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images | @Reply | Bookmark | Link | Email | Next Unseen |
using IIF in query criteria
Rav 

16 years ago
Access experience=advanced
Hi,
I'm trying to use IIF statement in the criteria of a field in a query. The field is called "Data From" and contains data such as "Job Sheets" & "Reception Database"

My IIF statement in the criteria section of the "Data From" field is

IIf([Forms]![FrmJobSheetsEntry]![ShowOnlyJobSheetsData]=True,"Job Sheets",Is Not Null)

The form FrmJobSheetsEntry contains a check box. If box is ticked, the query returns rows where "Data From" contains "Job Sheets", but unticked it does not return anything. I want it to return all rows. "Data From" field does not contain any null values.

How can I do this ?

Thanks for your help
 


Answer from Richard Rost:

You're using the IIF statement incorrectly. Plus, "Is Not Null" can't be used to set a value like that.

Here's what you should do: make an AfterUpdate event for your checkbox. In it say:

If ShowOnlyJobSheetsData = TRUE then
Me!RecordSource = "SELECT * FROM TableName WHERE [Data From]='Job Sheets'"
else
Me!RecordSource = "SELECT * FROM TableName"
end if

Obviously replace TableName with the name of your table.

Also, these tutorials will probably help you:

http://599cd.com/tips/access/iif-function?key=BlFAlEx

http://599cd.com/tips/access/afterupdate-event-vba?key=BlFAlEx

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
 
What's This?

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 9/30/2026 5:38:56 AM. PLT: 1s