Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 2nd, 2007, 03:36 AM
Authorized User
 
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default Logic builiding with Nested/Multiple IIF

Hi,

I am trying to build a logic with IIF...The tblEmployee New has a reconciled column which has the Word NO on it i want to convert it to YES based on the below given logic but its not working....

IIf([tblEmployee New]![Employee_ID] Like '0' & [tblEmployee New]![Dept] Like "Finance" Or "Sales","Yes",[tblEmployee New]![Reconciled])

Also how can i add multiple IIF statements for other employees in Depts like Sales or marketing based on the Employee_ID criteria.


 
Old May 2nd, 2007, 12:06 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This is not the proper syntax for an IIF statement. Do a search in the VBA editor for IIF to get the syntax.

How are you running this statement?

Also, when you use Like, you have to use a wildcard. So

IIf([tblEmployee New]![Employee_ID] Like '0' & [tblEmployee New]![Dept] Like "Finance" Or "Sales","Yes",[tblEmployee New]![Reconciled])

Should be

IIf([tblEmployee New]![Employee_ID] Like '0*' & [tblEmployee New]![Dept] Like "Finance*" Or Like "Sales*","Yes",[tblEmployee New]![Reconciled])

That is if you want the string to begin with the text, if in the middle, add wildcards to the front and back of the search string.

Did that help any?


mmcdonal
 
Old May 3rd, 2007, 04:12 AM
Authorized User
 
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Gotcha....thanks a ton

 
Old May 4th, 2007, 08:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Actually, the ampersand is concatenation, not AND. You also need to group the AND and OR. Do you want

Condition 1 AND (Condition 2 OR Condition3)

Or do you want

(Condition 1 AND Condition 2) OR Condition3

I assumed the former. Therefore, it would look like

IIf([tblEmployee New]![Employee_ID] Like '0*' AND ([tblEmployee New]![Dept] Like "Finance*" OR [tblEmployee New]![Dept] Like "Sales*"), "Yes", [tblEmployee New]![Reconciled])


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old May 4th, 2007, 09:52 AM
Authorized User
 
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Greg!!!







Similar Threads
Thread Thread Starter Forum Replies Last Post
Mulitiple/Nested IIF statements rohit_ghosh Access VBA 3 June 1st, 2007 10:44 AM
Nested IIF rohit_ghosh Access 5 May 4th, 2007 09:29 AM
Nested IIF Statement Help Needed Corey Access 4 November 17th, 2005 10:19 AM
Nested Query with an iif statment Corey Access 7 October 17th, 2005 04:40 PM
Nested Query with an iif statment part 2 Corey Access 1 October 17th, 2005 12:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.