Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query criteria And/Or not working

Status
Not open for further replies.

tchor7

Programmer
Jul 19, 2004
24
US
My If statement is too long (6 nested If's), so I tried to concatenate it by using And/Or operaters:

IIf(([tblProjects].[ProjTypeInitCat]= "Micro" OR "Macro") AND (Right([tblProjects].[ProjPhase],2) = (Format(Year(Now())+1,"yy"))) AND ([tblProjects].[BudgetClass]="Capacity" OR "-75 Quality" OR "-85 Quality"), "NextYr", "CurrentYr")

Please let me know what I am doing wrong.

Thanks,
Thoeum
 
It satisfies the IF statement, but produces both the if and the else results.

Thanks.
 
On each side of OR should be a condition/expression that evaluates to True/False. Your first OR expression should be one of these:

ProjTypeInitCat="Micro" Or ProjTypeInitCat="Macro"
ProjTypeInitCat In ("Micro", "Macro")
ProjTypeInitCat Like "M[ia]cro"



John
 
Something like this ?
IIf(tblProjects.ProjTypeInitCat Like "M[ia]cro"
AND Right(tblProjects.ProjPhase,2)=Format(Year(Now())+1,"yy")
AND (tblProjects.BudgetClass="Capacity" OR tblProjects.BudgetClass LIKE "-[78]5 Quality")
, "NextYr", "CurrentYr")


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top