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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iff and statement 1

Status
Not open for further replies.

aarellano

MIS
Oct 22, 2007
168
US
Hello, I am having a bit of a diffucult time with this statement
I am trying to do an "iif" "and" statement but I keep getting an error here is what I am trying
Code:
iif(wkctr like 'IND*' and DPTNO between 42 and 44, tmlb)

But I keep on getting Error if I take the

Code:
and DPTNO between 42 and 44

it works fine.

what would be the way to go about this one?


 
G'day fella,

An immediate if (IIF) needs a true action and an else action, you only have a true part so it doesn't know what to do if the condition is not met.

When debugging IIFs I sometimes find it helps to begin with ensuring the condition / test is being evaulated, then adjusting the returns when I'm happy. So test:

Code:
iif(wkctr like 'IND*' and DPTNO between 42 and 44, "Good","Bad")

and ensure that good or bad is returned depending on the values of wkctr and DPTNO you feed it...

Probably a silly question, but DPTNO is a number field right?

JB
 
JB,
thanks for taking the time,
Yes, the DPTNO is a number field. When I tried to use your suggestion I got "Bad" and instead of "Goog" I got "Error
 
Try with some brackets then:

Code:
iif([red](([/red]wkctr like 'IND*'[red])[/red] and [red]([/red]DPTNO between 42 and 44[red]))[/red], "Good","Bad")
 
Just mimicked the same thing here and works fine with or without brackets. Are you using this in VBA or as a field in a query?

Do the components of the check work:

Code:
iif(DPTNO between 42 and 44, "Good","Bad")

and

Code:
iif(wkctr like 'IND*', "Good","Bad")
 
argggg

I think you found it!!!!!!

it appears to be the dptno. could it be a text field then??
 
Check in the table mate. If it is text and cannot be changed then change your iif statement to:

Code:
iif(wkctr like 'IND*' and DPTNO In('42', '43', '44'), "Good","Bad")

JB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top