Return All Records if IIF statement is False (read: ["*"] in IIF)

Dudley

Registered User.
Local time
Today, 06:08
Joined
Apr 7, 2004
Messages
147
I wanted to give back to the forum and check out my latest insight. I’ve searched around (and worked out my recent understanding) on the forum but I haven’t found a single thread that laid it out so I could fully grok the issue/solution. So I’m hoping to produce a searchable thread to help those who come after.

I have a Contacts db where I need to limit the Contacts to those who match the person who is logged in, unless the person is the Adminstrator, who should see everybody. So I was thinking I needed an IIF statement in the criteria of the LoggedIn column of a SELECT query that would read something like: IIF(LoggedIn=Admin, “*”, LoggedIn). But Access refused to accept the solution, giving a “Data type mismatch in criteria expression” error. I tried double quotes instead of “*”, and “ “, but got the same message.

Searching, I found entries where people spoke of somehow doing it in the Field definition and getting a field of True/False for the column and then put “True” or “False” as the criterion for the column. Funny how it took so long to get my little head around it. <<sigh>> Finally I got it. So I added a new column to my query as such: Administrator: IIF(LoggedIn = Admin, “True”, “False”). This essentially tagged every returned record in the query as either being True or False depending on whether the Administrator is the person who is logged in. Then I added DLookup criteria to the other field that needed criteria (the one to pick the records belonging to the logged in person) along with “False” in the Administrator column in an “AND” statement and “True” for the Administrator as an “OR” statement without any additional criteria limiting the person logged in (since the Administrator doesn’t own any records). So it was like this:

Code:
LoggedInPerson | Administrator
Dlookup(…x)    |”False”
               |”True”


It all works great. Thanks everyone for your patience over the years in explaining this over and over again. Hopefully this helps someone else trying to do this in the future – and, naturally, if anyone has a correction/improvement to this, I trust that you’ll chime in.

Best,
 
I have a simple question (I hope). I want an expression that iif ([Dt] Between 08/01/2010 and 08/07/2010, "Wk1", "WK2"). All I get back when I run it is Wk2.
 
Explicit dates need date delimiters:

IIf([Dt] Between #8/01/2010# and #08/07/2010#, "Wk1", "WK2").
 
Last edited:
Try:
Code:
IIf([Dt] Between [COLOR="Red"]#[/COLOR]08/01/2010[COLOR="red"]#[/COLOR] and [COLOR="red"]#[/COLOR]08/07/2010[COLOR="red"]#[/COLOR], "Wk1", "WK2")

Er, Ninja'd :)
 
Last edited:
I'm sorry, but I'm just not getting it.

I have a query that gets results from a form. The form collects information on:

Audit
Year
Status

So that a viewer can look at all audits in 2011 or all closed issues or all issues related to a specific audit.

My query uses an IIF statement:
IIf(Len([Forms]![Form3_Play]![Audit_Name_Form_Value])>0,[Forms]![Form3_Play]![Audit_Name_Form_Value],"*")

If I read correctly above, I can't use "*", or Null in the FALSE position of the IIF statement. I need to add another column to my query. I'm just not getting what exactly I need to put in that extra column.

Any help would be appreciated. :confused:
 

Users who are viewing this thread

Back
Top Bottom