Solved

IIf issue

Posted on 2014-01-29
3
321 Views
Last Modified: 2014-01-29
I have this in the default value of a field on a form.

=IIf([Forms]![frmCustomers]![subfrmPets].[Form]![cboSpecies].[Column](1)<>"Cat" Or "Dog",True,False)

What I want to have happen is the checkbox (which is what this field is), needs to be checked (true) if [Forms]![frmCustomers]![subfrmPets].[Form]![cboSpecies].[Column](1) is not "Dog" or "Cat".

If it is either "Dog" or "Cat" then it should not be checked.

What is wrong with my syntax?

--Steve
0
Comment
Question by:SteveL13
3 Comments
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 39818188
=IIf([Forms]![frmCustomers]![subfrmPets].[Form]![cboSpecies].[Column](1)<>"Cat" Or [Forms]![frmCustomers]![subfrmPets].[Form]![cboSpecies].[Column](1)<>"Dog",True,False)
0
 
LVL 3

Accepted Solution

by:
DEVLitehouse earned 500 total points
ID: 39818203
You must directly compare both values. Also, if you're trying to make it so neither values are matched, you'll need to use "And" rather than "Or". So your code should look like this:
=IIf([Forms]![frmCustomers]![subfrmPets].[Form]![cboSpecies].[Column](1)<>"Cat" And [Forms]![frmCustomers]![subfrmPets].[Form]![cboSpecies].[Column](1)<>"Dog",True,False)

Open in new window

0
 

Author Comment

by:SteveL13
ID: 39818214
Not quite right.  It is checked even if  [Forms]![frmCustomers]![subfrmPets].[Form]![cboSpecies].[Column](1) = "Cat"
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now