Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 11th, 2008, 12:22 PM
Authorized User
 
Join Date: Sep 2007
Location: , , USA.
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
Reply With Quote
  #2 (permalink)  
Old February 11th, 2008, 04:15 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old February 15th, 2008, 09:19 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
  #4 (permalink)  
Old February 15th, 2008, 10:07 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:46 PM.


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