472,956 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,956 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 2127

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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.