By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,620 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,620 IT Pros & Developers. It's quick & easy.

Parameter query using criteria and IIf function

P: 1
I need to create a query using inputs from my form, it's check button. What I wish to do is when the check button is ticked it will show me open records or show me all records. Open records are those for which closure date is null.
Expand|Select|Wrap|Line Numbers
  1. Expr1: IIf([forms]![Main]![OpenOnly]=True,IIf(IsNull([QA Closure Date]),1,0),1)
This code is working well but I am not understanding the '1' in the end, also I have to put a 1 in the criteria section of the design view. Is there a thing that Access assigns 1 to all the records by default or is it because of my code?
Feb 19 '19 #1
Share this Question
Share on Google+
1 Reply


twinnyfo
Expert Mod 2.5K+
P: 3,284
Sanchi,

Welcome to Bytes!

It appears that your criteria expression is more useful for counting records, but it also works to select records, tooI have used such designs in the past also. By having the expression resolve to either a 1 or a 0, having the 1 in the Criteria line allows you to select only those records which resolve to 1 which, in this case is those records in which OpenOnly is checked and Closure date is Null OR OpenOnly is Unchecked.

However, an easier expression might be:

Expand|Select|Wrap|Line Numbers
  1. (([forms]![Main]![OpenOnly] And IsNull([QA Closure Date]) Or Not [forms]![Main]![OpenOnly])
With True in the Criteria section.

Im not sure if any of this answers your question, but Im not sure of the exact question.

Hope this hepps!
Feb 19 '19 #2

Post your reply

Sign in to post your reply or Sign up for a free account.