A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

iif statement in query



 
 
Thread Tools Display Modes
  #1  
Old February 22nd, 2007, 05:34 PM posted to microsoft.public.access.queries
Joel Allen
external usenet poster
 
Posts: 59
Default iif statement in query

Hello,

I'm trying to use an "OR" in this iif statement and it's not working. Can
somebody please help?
My goal is: if ProductResultBDHC contains C or P, then make it = 10. If
there is no C or P, then it will = 5.

LeadTime: IIf([ProductResultBDHC] Like "*C*" or IIf([ProductResultBDHC] Like
"*P*",10,5))

Thanks for your help,
Joel


  #2  
Old February 22nd, 2007, 05:45 PM posted to microsoft.public.access.queries
Carl Rapson
external usenet poster
 
Posts: 517
Default iif statement in query

Remove the second IIf:

IIf([ProductResultBDHC] Like "*C* or [ProductResultBDHC] Like "*P*", 10, 5)

Carl Rapson

"Joel Allen" wrote in message
...
Hello,

I'm trying to use an "OR" in this iif statement and it's not working. Can
somebody please help?
My goal is: if ProductResultBDHC contains C or P, then make it = 10. If
there is no C or P, then it will = 5.

LeadTime: IIf([ProductResultBDHC] Like "*C*" or IIf([ProductResultBDHC]
Like "*P*",10,5))

Thanks for your help,
Joel



  #3  
Old February 22nd, 2007, 05:49 PM posted to microsoft.public.access.queries
Jason
external usenet poster
 
Posts: 713
Default iif statement in query

Not sure - might try taking out the second IIf statement and see if it works.
--
Thanks,

Jason


"Joel Allen" wrote:

Hello,

I'm trying to use an "OR" in this iif statement and it's not working. Can
somebody please help?
My goal is: if ProductResultBDHC contains C or P, then make it = 10. If
there is no C or P, then it will = 5.

LeadTime: IIf([ProductResultBDHC] Like "*C*" or IIf([ProductResultBDHC] Like
"*P*",10,5))

Thanks for your help,
Joel



  #4  
Old February 22nd, 2007, 05:50 PM posted to microsoft.public.access.queries
fredg
external usenet poster
 
Posts: 4,386
Default iif statement in query

On Thu, 22 Feb 2007 09:34:53 -0800, Joel Allen wrote:

Hello,

I'm trying to use an "OR" in this iif statement and it's not working. Can
somebody please help?
My goal is: if ProductResultBDHC contains C or P, then make it = 10. If
there is no C or P, then it will = 5.

LeadTime: IIf([ProductResultBDHC] Like "*C*" or IIf([ProductResultBDHC] Like
"*P*",10,5))

Thanks for your help,
Joel


Too many IIF's.
The letters C or P can be anywhere in the field?

LeadTime: IIf([ProductResultBDHC] Like "*C*" or [ProductResultBDHC]
Like "*P*",10,5)



--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #5  
Old February 22nd, 2007, 10:05 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default iif statement in query

On Thu, 22 Feb 2007 09:50:22 -0800, fredg
wrote:

The letters C or P can be anywhere in the field?

LeadTime: IIf([ProductResultBDHC] Like "*C*" or [ProductResultBDHC]
Like "*P*",10,5)


or:

IIF([ProductResultBDHC] Like "*[CP]*",10,5)

Putting a charlist in brackets will match any one of the characters.

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:44 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.