Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

IIf issue

Posted on 2014-01-29
3
Medium Priority
?
333 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 2000 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

885 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