Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 February 11th, 2008, 12:22 PM
Authorized User
 
Join Date: Sep 2007
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default help with IIf function

Hi All -

Is it possible to display more than one true value in an IIf function. For example, I have 2 bounded fields on a form - Place and Language. In the validation rule for Language, I want to display that if Place = 'Mexico', then Language can be 'English' or 'Spanish'.

IIf([Place]='Mexico', 'English' or 'Spanish', 'Other')

This doesn't work. How can i do this ??

Thanks
 
Old February 11th, 2008, 04:15 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

How is the user selecting these values? You should use cascading combo boxes such that if Place = Mexico, Language selections are limited to English or Spanish.

You can also create rules using select case statements that will not limit you to one Place, like:

Select Case Place
   Case "Mexico"
     If Me.Language <> "English" AND Me.Language <> "Spanish"
          'some action
     Else
          'some other action
     End If
   Case "Spain"
     If Me.Language <> "Spanish" Then
          'some action
     Else
          'some other action
     End If
End Select

Put this on the Before Insert and Before Update events of your form.

Anyway, maybe not as pretty, but works as well. Did that help?

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old February 15th, 2008, 09:19 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

Well, it looks like you're using strings as the true/false statement. So you would do this:

IIf([Place]="Mexico", "English or Spanish", "Other")

If it's Mexico, the string is "English or Spanish".
If it's not Mexico, the string is "Other".




Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old February 15th, 2008, 10:07 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I think he wants to check for a value of "English," or a value of "Spanish," not set the value "EnglishorSpanish." So either a nested IIF, or a nested conditional will have to do it.




mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
iif function rohit_sant SQL Server 2000 11 December 24th, 2009 04:04 AM
IIf umeshtheone Beginning VB 6 3 June 21st, 2007 12:24 AM
IIf Function - Multiple conditions carrie09 Access 2 June 13th, 2007 10:27 AM
EVAL becomes failed, with IIF and Replace Function AbrarNazeer ASP.NET 2.0 Professional 0 July 6th, 2006 06:53 AM
Is there an IIF Function in SQL Server? treadmill Classic ASP Professional 4 January 17th, 2005 06:57 AM





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