Wrox Programmer Forums
|
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 1st, 2007, 08:44 AM
Authorized User
 
Join Date: May 2007
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple IIF Statements

Hi,

Can anyone tell me the right way of writing multiple/Nested IIF statements. I am having a problem with Syntax. Also how many multiple IIF statements can i right in an expression. I am asking this because i have to change a field couple of times based on several conditions......with a single expression which has multiple IIF statements......also can somebody let me if this not possible in SQL is there a way to do this in VBA and add it to the query...to add to it i am not using a form to run this query....

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

What do you need to do? You can always do it in code.



mmcdonal
 
Old May 7th, 2007, 03:05 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

"IIf" stands for "Inline Ifs" and by definition must be written on a single line. Get arround the problem by writing some code in the form's Module as follow:

If (condition1) Then
  Code to handle condtion1
ElseIf (Conditon2) Then
  Code to handle condition2
ElseIf (as Many additional conditions as you may have) Then
  Code to handle those conditons
Else (final condtion) Then
  conde to hand the final condion
End If

Each of the "code to handle..." sections could have i"If..then"
statements embedded within it to allow for almost infinite branching possibilities. You might also try "select case" statements.





Similar Threads
Thread Thread Starter Forum Replies Last Post
IIF multiple criteria stealthdevil Access VBA 10 November 28th, 2007 11:37 AM
IIf Function - Multiple conditions carrie09 Access 2 June 13th, 2007 10:27 AM
Mulitiple/Nested IIF statements rohit_ghosh Access VBA 3 June 1st, 2007 10:44 AM
Logic builiding with Nested/Multiple IIF rohit_ghosh Access 4 May 4th, 2007 09:52 AM
Multiple IIF statements Corey Access 1 November 16th, 2006 05:25 PM





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