473,320 Members | 1,732 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,320 software developers and data experts.

Nested IIF Statement

Dear All,

I am experiencing a problem with an IIF statement in Access. As I have never created one of these before I am having real problems getting my head around them. What I am trying to do is write an IIf statement that will bring out only information that I require and because I am asking for several things to be done there is a conflict somewhere and it just is not working.

The statement I am using is below. The fields that I am using are "Cycle" and "Comment", but there are others, but not knowing which line or field to put this information in I am at a loss. Could some kind person please point me in the right direction as to how I would link a number of different fields and criteria.

=IIF([cycle]="02" and [comment]="RFC11878"))
Mar 22 '07 #1
6 2541
Denburt
1,356 Expert 1GB
Is this in a query, Controlsource, or VBA?
I am asking for several reasons, anyhow your statement addresses the criteria but you left out the part to show that the criteria is met or not:

Expand|Select|Wrap|Line Numbers
  1. =IIF([cycle]="02" and [comment]="RFC11878","ThenDoThis","OtherwiseDoThis")
  2.  
The following can be replaced with field names and even calculations[ThenDoThis] + [ThenDoThis] or as a constant such as what I showed.
"ThenDoThis"
"OtherwiseDoThis"
Mar 22 '07 #2
Denburt
1,356 Expert 1GB
I am still not awake yet need more coffee. I reread your title and if you need to nest them then it might look more like the following:

Expand|Select|Wrap|Line Numbers
  1. =IIF([cycle]="02" and [comment]="RFC11878",IIF(1=1,1,2),IIF(2=2,2,1))
  2.  
Mar 22 '07 #3
FAO Denburt,
Sorry If I din't make it clear. I am actually trying to do this on the query itself. What I am trying to do is to produce a report and if the records do not match the criteria then I don't want them counting in my query. Hope this helps.
Mar 22 '07 #4
Denburt
1,356 Expert 1GB
So you are saying that you are buiding criteria for a field that will show results if the criteria is met

Expand|Select|Wrap|Line Numbers
  1. MyNewFieldName:IIF([cycle]="02" and [comment]="RFC11878",IIF(1=1,1,2),IIF(2=2,2,1))
  2.  

or are you actually trying to create criteria to remove the records you don't want(looking at it in SQL view it would be a where or having statement depending if your query has totals):
Expand|Select|Wrap|Line Numbers
  1. Where [cycle]="02" and [comment]="RFC11878"
  2.  
Mar 22 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Chris

If you give us the logic in English of what you are trying to do with your query we will be beter able to help.

Mary
Mar 25 '07 #6
missinglinq
3,532 Expert 2GB
Or if not in English, at least in American! ;0)>
Mar 25 '07 #7

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

Similar topics

2
by: d2r2 | last post by:
Hi, I'm trying to run a nested (UNION) query against a MSAccessXP database (version 2002; build 10.6501.6714; SP3) In Access the SQL-statement executes just fine. When I run it in a asp-page I...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
13
by: PeterZ | last post by:
Hi, Back to basics! My understanding is that the only way to exit a For-Next loop prematurely is with the 'break' keyword. How are you supposed to do that if you're inside a Switch...
4
by: ECathell | last post by:
I had read an article at one time that suggested a pattern to get around deeply nested if..then..else hell... Can anyone point me in that direction? select case statements wont work for me in...
9
by: John Sidney-Woollett | last post by:
Is it possible to use the dblink and dblink_exec features from inside pl/pgsql functions to mimic the behaviour of nested transactions by calling another function or executing some SQL via the...
37
by: Tim N. van der Leeuw | last post by:
Hi, The following might be documented somewhere, but it hit me unexpectedly and I couldn't exactly find this in the manual either. Problem is, that I cannot use augmented assignment operators...
78
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only...
5
by: =?Utf-8?B?QUEyZTcyRQ==?= | last post by:
Could someone give me a simple example of nested scope in C#, please? I've searched Google for this but have not come up with anything that makes it clear. I am looking at the ECMA guide and...
9
by: Gabriel Rossetti | last post by:
Hello, I can't get getattr() to return nested functions, I tried this : .... def titi(): .... pass .... f = getattr(toto, "titi") .... print str(f) .... Traceback...
7
by: brasse | last post by:
Hello! I have been running in to some problems when using contextlib.nested(). My problem arises when using code similar to this: from __future__ import with_statement from contextlib...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.