Nested IIF Statement in a query

I'm trying to set up a nested IIF statement in a query and I'm striking out.

Basically I'm trying to do the following:

If "Field A" and "Field B" are both blank, "Enter This Text" OR If "Field A" 
is NOT blank, "Enter That Text".

Any ideas??
Thanks in adavnce.
Frank
1
Utf
1/22/2010 2:34:01 PM
access.queries 6343 articles. 1 followers. Follow

4 Replies
4954 Views

Similar Articles

[PageSpeed] 10

hi Frank,

On 22.01.2010 15:34, FrankTimJr wrote:
> I'm trying to set up a nested IIF statement in a query and I'm striking out.
>
> Basically I'm trying to do the following:
>
> If "Field A" and "Field B" are both blank, "Enter This Text" OR If "Field A"
> is NOT blank, "Enter That Text".
Iif(Len(Trim(Nz([FieldA], ""))) > 0,
     "Enter That Text",
     Iif(Len(Trim(Nz([FieldB], ""))) = 0), "Enter This Text", "???")

mfG
--> stefan <--
0
Stefan
1/22/2010 2:53:00 PM
You haven't indicated what to do if A is blank and B is not.
Assuming you leave the text blank for this column, perhaps something like 
this:

IIf([A] Is Null, IIf([B] Is Null, "Enter this text", Null), "Enter that 
text")

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"FrankTimJr" <FrankTimJr@discussions.microsoft.com> wrote in message 
news:A6EB05D6-9956-4C41-A343-2DEF57DBDB67@microsoft.com...
> I'm trying to set up a nested IIF statement in a query and I'm striking 
> out.
>
> Basically I'm trying to do the following:
>
> If "Field A" and "Field B" are both blank, "Enter This Text" OR If "Field 
> A"
> is NOT blank, "Enter That Text".
>
> Any ideas??
> Thanks in adavnce.
> Frank 

0
Allen
1/22/2010 2:55:08 PM
Frank -

You didn't say what the result should be for when A is null and B is not, so 
I made something up for that.   Here goes:

IIF(isnull([Field A]),iif( isnull([Field B]),"Enter This Text","A null B not 
null"),"Enter That Text")

-- 
Daryl S


"FrankTimJr" wrote:

> I'm trying to set up a nested IIF statement in a query and I'm striking out.
> 
> Basically I'm trying to do the following:
> 
> If "Field A" and "Field B" are both blank, "Enter This Text" OR If "Field A" 
> is NOT blank, "Enter That Text".
> 
> Any ideas??
> Thanks in adavnce.
> Frank
0
Utf
1/22/2010 2:56:01 PM
IIF([FieldA] is Null and [FieldB] is Null,"Both Null"
, IIF([FieldA] is not null,"Field A has a Value",
, IIF([FieldB] is not null,"Field B has a Value",Null)))

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

FrankTimJr wrote:
> I'm trying to set up a nested IIF statement in a query and I'm striking out.
> 
> Basically I'm trying to do the following:
> 
> If "Field A" and "Field B" are both blank, "Enter This Text" OR If "Field A" 
> is NOT blank, "Enter That Text".
> 
> Any ideas??
> Thanks in adavnce.
> Frank
0
John
1/22/2010 3:11:46 PM
Reply:

Similar Artilces:

Query Problem 03-27-10
Hi, I have 2 tables, tbBaby and tbVaccineInjection. tbBaby stores the babies' personal data like Name, BirthDate etc., tbVaccine stores VaccineName, DoseNumber (1st, 2nd, 3rd, etc.) and InjectionDate, etc. These 2 tables are one to many in relation, because each baby may have several vaccinations on different dates. I'd like to build a query to retrieve babies with their most recent injection date, i.e. only one record for each baby with latest injection date. my query is as follow SELECT tbBaby.*, tbVaccine.* FROM tbBaby INNER JOIN tbVaccine ON tbBaby.ID=tbVaccine.B...

Append query bloat
I have an access database where I use an append query quite often. I will use this same query over and over by changing the table I'm appending from, then I save the query. During the save process, the database bloats from ~50KB to ~150KB. Our company recently upgraded to 2007 and that is when I noticed the problem. Is there a way to stop this from happening? I can manage it by compacting and repairing after each save, but recently I added 4 tables in one day, so this was a pain. Thanks Don't even worry about it. An Access file can be up to 2 GB in size. 150 KB ...

Does SQL Run Behind Queries?
Access 2007 When I run a query does Access, "go away" and run the SQL for what I see in the GUI? If the answer is, "yes" is there anything that I can switch on to see the SQL that it is running? What I would like to do, if it is possible, is to see the query in the GUI and, at the same time, see the SQL that is being used to select the data from the database; that way I can understand things (exactly what is happening) more clearly and more quickly. TIA for any replies. trip_to_tokyo wrote: > Access 2007 > > When I run a query does...

Printing Statements?
I'm a new user. Printing my first statements. How Do I get rid of the Minimum Payment field or change the amount to show the current balance? -- JD Hi JD - Thanks for your note. In order to modify the account statement, you will need to modify the XML file. The file name and path can be found in Store Operations Administrator, in the Configuration dialog, Templates tab. Typically, the file is Statement.XML and is located in c:\program files\microsoft retail management system\store operations\receipt templates folder. Once you find the file used for your account statements, locate...

Database Query #4
I have created a data table in a worksheet and named it “data”. Then I created a separate worksheet, in the same workbook, and created a database query of the data table, by using Data…Import External Data…New Database Query…Excel Files* and defining the database name by browsing to the same workbook. The query worked fine. However, when I moved the workbook (which included the data source) to a different folder and tried to refresh the database query, I got the following error message: “[Microsoft] [ODBC Excel Driver] The Microsoft Jet database engine could not find the object ‘data’...

a long thread of if-then statements
Hi. I'm using MS Excel Xp. Here's my problem: :confused: I have a large flatfile of our sales people and I need to do a pivot table on them. but before that, I need to create a new column which contains certain tiering of their earnings. For example: Name: Earnings Tier Person A $5000 $0 - $10,000 Person B $34,500 $30,001 - $40,000 Person C $1M $990,000 - $1,000,000 Person D $2.5M $2,490,001 - $2,500,000 The column "Tier" is the one I need to create. How do I create a long IF-TH...

DNS clients Does not query the secondary DNS
Hi, I have 2 w2003 Dcs - both DNS servers Primary and secondary. I have Clients running XP static Ip and in both DNS servers IP is configured as Primary and Secondary DNS. My Primary DNS server went down, all clients are not quering the secondary! using NSLOOKUP it showed that clients are still querying the primary with a tomeout error !! all name resoultiond stoped in the organization! any idea? tx NsLookup does not automatically fall through to alternate DNS servers, it is not a good way to test server redundancy. If you ping a host, which will use the DNS Cl...

Calculate difference in rows in a query
I have a query that calculates how much revenue is claimed by month per job but then I have to take the new month less the prior month. The problem is the data is in row format. I don't know how to subtract February from January, March from but don't know how. I know how to do it in Excel but not Access. Please help... Example: Order Month JTD Clm Variance 101026521 January $511,525 $0 101026521 February $511,525 $0 101029438 January $1,238 $0 101029438 February $3,713 $2,475 101033168 January $21,465 $0 101033168 February $51,460 $29,995 101034011 Janu...

How to use colmn headings in paramter query
Sorry if this has been asked before, but I am not able to locate it if it has. But here is my delima: I need to be able to select the salesperson sales based on the month (1-12) from table 1. I* can create a parameter query, but am not sure hwo to query onlya certain month. table1 ID salesperson 1 2 3 4 5 6 7 8 9 10 11 12 1 joe 12 0 0 2 12 0 1 1 5 7 8 10 2 steve 2 5 6 18 0 0 2 3 4 11 12 1 select * from table1 where salesperson =joe and .... that is where I get stuck. I need to be able to select a column he...

How do you nest templates in XSLT?
I know you CAN'T nest templates, so what would be the logic to use otherwise? Here's what I am doing: I have a template set to match a specific node based on one of it's elements. If it finds it, it renders it. I then want to see if that node has any children. If it does have children, render that. Since I can used a nested template to see it if has children, what logic/method should I be using? -Darrel > If it finds it, it renders it. I then want to see if that node has any > children. If it does have children, render that. Since I can used a nested > template to s...

Advanced month deposit should be shown in the statement after PTR
Posting for Kenny Wu Of Professional Advantage PTY LTD. Details: After running PTR on a given cut-off date (e.g. 8/31/2007). Transaction's Apply date field like 9/31/2007 should still be shown in the RM statement eventhough you have posted them on or before the PTR's cut-off date. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-...

Extracting invoice data from GP 9 using a SQL query (ODBC)
I'm working to extract invoice detail information from a client's GP 9 MSSQL database, with the goal of being able to mock up their invoices in external systems. Just to keep things interesting, they aren't using GP to it's maximum ability - quotes are generated from another software package, and when converted to a sale, minimal data is entered into GP and processed (such as shipping address, job name, job number, PO number, and occasionally a line it of what appears to be free-form text. I have hard copies of several invoices, various web resources, and access to t...

Query Does Not Count "2" Records
Good Evening Everyone... I have a bit of a logical puzzle that I need to solve. I have various queries which have various criteria for them. One query involves retirees or spouses being under the age of 65 and the other involves retirees or spouses being over the age of 65. Both the retiree and spouse are listen in the same records and on one line of the master table and queries. The situation that I am running into is that I can have a retiree who is over 65 and a spouse under 65 and the record comes up twice in the two different queries b/c it meets the criteria, which is perfect. What...

Web Query Help...
If I try and use a web query with the following site http://www.sportsline.com/mlb/stats/playersort/regularseason/yearly/MLB/P I get a message that says the web query returned no data. I click on the arrow right by player and it highlights all the players names and their stats. Anyone know why it doesn't import the data into excel? Is there too much data? Thanks Works fine for me, although one have to do some editing since it imports some trash as well (I would import it, then select the table itself from the import and copy and paste into a new sheet, then import the next 50 and...

If Statements #3
Hi all I am new to this, can someone, please help me with this. I wont to now how to evaluate two or more logical conditions if they are true or false using if functions for example. If total purchases in A2 are greater than $7000.00 deduct 15% from those purchases and if purchases are greater than $5000.00 deduct 10% of purchases otherwise purchases stay the same. How would I do this if funtion, Please, maybe use a or somehow? Cheers Mark -- burkey ------------------------------------------------------------------------ burkey's Profile: http://www.excelforum.com/member.php?actio...

If Statements in Access
Hello I am currently using the following IF statement in Excel however i will need to convert it so that it will work for me in Access =IF(Expiry Date<>"",IF(Expiry Date <Todays Date,"Cease Working ",IF(todays date> Expiry Date -60,"Submit New Application"," ")),"") Can someone please help Thanks Longbeach LongBeach, I take it you're updating a text control with text according to the value of [Expiry Date] vs. the current system Date... And, you don't need the If [Expiry Date] <> "". If it's...

Fetch XML to Query Expression
I'm trying to convert the following Fetch XML statement to a Query Expression to post using the RetrieveMultiple webservice: <fetch mapping="logical"> <entity name="role"> <attribute name="name" /> <link-entity name="systemuserroles" from="roleid" to="roleid"> <filter> <condition attribute="systemuserid" operator="eq-userid" /> </filter> </link-entity> </entity> </fetch> I haven't been able to find an documenta...

Query Output
Help, I am working with make table queries. I have a A make table query and a B make table query each with various information that the query has preformed. I am trying to get the following output into a text file. A Make Table Information B Make Table Information A Make Table Information B Make Table Information etc. There are over 300 items in each table. Each A Corresponds with a B. I need to keep the 2 records separate for where i have to upload them. I tried having a common identifier for the two tables and creating a big query with all the information on, but i ...

Collections Management Default Statement ID
In GP 10, we've assigned a Default Statement ID in the Collections Management Local Setup window. However, when we go to the Collections Management Print Selection window and put a checkmark beside Print Statement, the Statement ID is not defaulting in. This worked in GP 9. Did this break in GP 10? Or, are we missing something? ...

IF Statement....If False how ignore referenced cell
Hi, Is there a way using a "IF" statement that when the statement is false it ignores the cell it is writing to. For example: If(A1=1,B16,ignore) When it looks at cell A1 it will write what is in cell B16 (let's say 7). Next I want to change cell A1 to a 2 (because my value in B16 has changed), which makes the original IF statement False and typically overwrites the value in the cell with False, " " or "0". I would like it when FALSE, to leave the value 7 and not overwrite it.. Hope this makes sense. Any help would be greatly appreciated. Hi th...

Query-Based E-mail Groups
I have created query-based email group that contains 1,600 users. When I send an email to that group, about 350 users don't get the message. I as the owner of the group get an undeliverable stating: The e-mail system limits the number of recipients that can be addressed in a single message. Send the message multiple times to fewer recipients. For all 350 users. So I check my "Message Delivery Properties" in ESM. I have my "Recipient Limits" set to 2,000. I double checked the query-based email group to make sure it was under 2,000 recipients and ...

Suggestions for table or query to track movement
I have a table for employees that includes the usual description fields for employees. This is one of my master tables with the employee ID being the primary key. Then I have another table that stores all employee hours that I add on to monthly via an import from Excel (emplID is foreign key). I want to keep track of all of the employees that are new or terminate. I’d like Access to recognize if an employee is missing or new and later be able to create a report for recent new hires or terminations. I may be expecting too much and if so please give me your opinion on this. ...

Easy income statement question
I have a quick question regarding the income statement. Under "Revenue", are those values based on the time of sale or when we actually get paid for those services/product? And, under "Cost of Revenue", are those values based on the time of sale or when we actually get paid for those services/product? Thanks for your time. Good questions and the answer to both depends upon if you are using accrual-based accounting or cash-based accounting. In an accrual world, you generally don't worry about what's been paid by a customer. If you post a customer invoice, ...

Calculating the Difference in a Query
I need to calculate the difference between two fields in a query. The query is called “qryRemote” and within the query are the fields “10-8Time” and “10- 97Time”. The data entered into these fields are in the format “0000” through to “2400”. I need to subtract the “10-8Time from the “10-97Time” and then sum the results and display the result in a report. For example, after the query is run the results are: 10-8Time 10-97Time --------------------------------- 1307 1331 1858 1909 2018 2023 First the difference is determined: 10-8Time is subtracted form t...

Outlook 2000 Calendar Text Entry query. Help!
Husband and I are both retired and have never used Outlook before, even though it's installed on our home computer. Now that we have more time on our hands, we're using the Outlook monthly calendar: we print out a "blank" month at a time, pop the page into a ring bind folder, and then write (by hand) notes on the various days. We would like to be able to do this on-screen though, rather than with a pen! We're planning a day-by-day schedule for a holiday next February but we cannot work out how to "write" timetable notes into the squares for each separate...