Solved

microsoft access 2010 iif criteria in query

Posted on 2014-03-17
2
703 Views
Last Modified: 2014-03-17
I have a simple query:
SELECT MEMBERS.*
FROM MEMBERS

But, dependent on what the value of tempvars!user_level is, I want it to do one of these two actions:
if tempvars!user_level = 1 then it needs to do this:
 - "WHERE Province = tempvars!province"
if tempvars!user_level = 2 then it needs to do this:
 - "WHERE Province > 0

I've tried to construct this using IIF, but can't see how to do it. I have tried:

SELECT MEMBERS.*
FROM MEMBERS
IIf(tempvars!user_level = 1,(Province > 0,TempVars!province)
0
Comment
Question by:rick_danger
[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 48

Accepted Solution

by:
Dale Fye earned 500 total points
ID: 39933830
SELECT MEMBERS.*
FROM MEMBERS
WHERE (tempvars!user_level = 1 AND Province = Tempvars!Province)
OR (tempvars!user_level = 2 AND Province > 0)
0
 

Author Closing Comment

by:rick_danger
ID: 39933859
Excellent solution. So simple - I don't know why I didn't think of that!

Thanks for a very clear solution.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 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