473,416 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Trouble utilizing nested IIf Statement

22
Hello - and thank you for reading my question!
I have experience with IIf and Nested IIf, but I am completely stuck on this one. I have written in 15 versions of syntax and cannot get it to work.
Here's what I need - I have an query that I need to analyze four fields of each record. One of these is fields always contains a value, the others vary. They are all number fields, but the numbers are not for expressions - they are just ID's numbers within the company. There are two record sources bringing these into the query.
I am trying to create a field with my IIf statement that will categorize the record based on the pattern of data in these four fields.
I want a text code filled in as an identifier.
Here are examples of how the IIf will read, and what will be returned in IIFCODE:
PrimaryRep SalesRep2 SalesRep3 InvSplit IIFCODE:
774 *null* *null* *null* N
184 1125 1126 *null* O3
774 887 *null* *null* O2
774 239 *null 50 RS

Here are my closest examples, where sql is actually trying to run it, but I can't get either to work:
#1)
When this is entered, the Error is Too many closing parentheses, and when I take the last parentheses out, access changes my trueparts (i.e. "O2") to bracketed ["O2"], so it's putting up parameter boxes that I ok through, and returns a blank field:
  1. IIf( ([SalesRep2] Is Not Null) And ([SalesRep3] Is Null) And ([InvSplit] Is Null),”O2”,
  2. IIf( ([SalesRep2] Is Not Null) And ([SalesRep3] Is Not Null) And ([InvSplit] Is Null),”O3”,
  3. IIf (([SalesRep2] Is Not Null) And ([SalesRep3] Is Null) And ([InvSplit] Is Not Null),”RS”,”N”))))

#2
This errors variations of with or without parentheses, and returns wrong number of arguments:
  1. IIf(IsNotNull([SalesRep2]) And (IsNull([SalesRep3]) And (IsNull([InvSplit]),”O2”,
  2. IIf(IsNotNull([SalesRep2]) And (IsNotNull([SalesRep3]) And (IsNull([InvSplit]),”O3”,
  3. IIf((IsNotNull([SalesRep2]) And ([IsNull[SalesRep3]) And (IsNotNull([InvSplit]),”RS”,”N”)))

The falsepart is if all of these are null, across each record - IIFCODE is N
Can anyone offer the correct syntax I would use to achieve this?

Thanks in advance!
Mar 5 '21 #1
0 2423

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fernando Rodriguez | last post by:
Hi, I have a parameter defined in a module, called PREVIEW. Many functions use it's value to modify their behavior. A function called dispatch checks the user arguments in sys.argv and calls...
1
by: Glenn Venzke | last post by:
I'm trying to write/compile a class that (1) accesses all the intrinsic ASP.NET objects (2) Uses Server.Transfer to redirect a user back to a log in page if a session has expired. I've gotten...
0
by: lowellturner | last post by:
We recently had to reload an app to a Linux server from its Window counterpart. I've tried setting the lower case global in my.cnf to al three values, but none work. Previously, this worked fine....
3
by: Michele Simionato | last post by:
I am getting trouble with nested triple quoted strings in doctest. For instance $ cat x.py """ >>> dummy = ''' something here ''' """
10
by: Philip Ronan | last post by:
Hi, I'm having problems embedding alternative content with nested OBJECT tags. Take a look at <http://www.japanesetranslator.co.uk/chihiro/map.html> The map on this page is available in SVG,...
1
by: KBuser | last post by:
Preface: I'm building an intranet site to build custom queries against our SQL Server (2000) db; The page is developed in ASP.net (2.0) with C# Codebehind. I dynamically generate and populate...
3
by: mrquan83 | last post by:
I'm using Nini from http://nini.sourceforge.net to read and write XML files. I'm having trouble creating nested 'configs' (Sections) however. This is a sample of my code.... ----- vb.net...
2
by: execworks | last post by:
I would appreciate help with the following Function. The SQL statement below returns a Recordcount = 0, yet, when it runs in the query designer it returns the correct count of 40 Private...
2
by: John | last post by:
Hi, I'm having trouble with nested master pages (and creating the same behaviour as Scott Guthrie's blog post...
1
by: ehpratah | last post by:
hi im having trouble in my codes..anybody please help me in my code i always get the last condition in my if statement..i always get the Mercedes Benz even i choose already another type of car here...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.