Access 2007-2016
Access 2000-2003
Access Seminars
TechHelp Support
Tips & Tricks
Access Forum
Course Index
Topic Glossary
Insider Circle
 
Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us  
 
NOTICE: I am right in the path of Hurricane Irma, please read this   dismiss

Forums     

Microsoft Access Forum
By Richard Rost   Richard Rost on Facebook Richard Rost on Twitter Richard Rost on Google Plus Richard Rost on LinkedIn Email Richard Rost

 
This forum is for the discussion of Microsoft Access.

Access is my personal specialty. Have questions? Comments? Want to discuss how to do something? Post it here. Also, I get a LOT of questions sent to me in Email from people around the world. I'll post the interesting ones in here. Feel free to comment on them.

Click Here To Subscribe to this forum and receive an email update whenever new posts are added, just scroll down to the bottom of this page and enter your email address in the comment form.

Permanent Link
Keywords: microsoft access forum
Post New Topic

Read Nested IIf Functions by Stephen B @ 12/15/2016
Hi Alex. I tried your suggestion and got the same error message in the query. I simplified it even more, using

IIf([RoomID]=2,[BasicTourCost],"NOT CALCULATED")

I got the same error message.

I then changed the join type between the tables in the query to show ALL records from the TourT, irrespective of whether there was a booking.

When I re-ran the query I saw the text message, from the ELSE part of the IIF function was being displayed. The problem was only occurring when a booking was made.

To cut a very long story short, when I examined the field properties of the RoomID in the TourXClientT (where it is a foreign key) I found it set to TEXT instead of NUMBER. This prevented the relationship link being set up properly and was the cause of the whole problem.

Such a simple thing caused me to waste many hours but it's a lesson I will never forget. Thank you so much for your suggestion that finally helped me to identify the cause of the error message.


Reply from Alex Hedley:

Glad you got it working, Number/Text issues can occur lots so it's a good one to keep an eye out for.
Show Just This Thread        Post Reply
Read Nested IIf Functions by Stephen B @ 12/13/2016
I created a calculated query to evaluate the total cost of a holiday. It should be a fairly simple calculation, selecting a different price, depending on the type of room required.

RoomID shows the different category of room. Below is the calculated query field which is causing an Error message each time I run it. I have thoroughly checked all of the field names and the logic. I cannot find what is causing the error message. All fields in the Table that have no value have been set to zero.

Any suggestions please?

TotalTourCost:
IIf([RoomID]=2 Or [RoomID]=6,[BasicTourCost],
IIf([RoomID]=3 Or [RoomID]=7,[CostSharedWithUpgrade],
IIf([RoomID]=4,[CostSingle],
IIf([RoomID]=5,[CostSingleWithUpgrade],0))))


Reply from Alex Hedley:

Try one at a time, does it work, yes, add another.
IIf([RoomID]=2 Or [RoomID]=6,[BasicTourCost])

Expert 8
Tip
Glossary
Show Just This Thread        Post Reply
Read IIF function by Virginia M @ 6/12/2016
Dear Alex, thank you. Sometimes it need someone with fresh eyes to spot a mistake I could not spot for several hours actually days! the following IIF function is working perfectly, thank you  
IIf([Noofdays]<=8,1,IIf(Int([Noofdays]/7)=([Noofdays]/7),([Noofdays]/7),IIf([Noofdays]<>Int([Noofdays]/7),(Int([Noofdays]/7)+1))))


Reply from Alex Hedley:

Indeed, another pair of eyes is always useful :)
Show Just This Thread        Post Reply
Read IIF function by Virginia M @ 5/30/2016
Hi guys, I am pulling my hair out trying to figure out why the following IIF expression is not working
IIf([Noofdays]<=8,1,IIf(Int(([Noofdays]/7)=([Noofdays]/7)),([Noofdays]/7)),Int(([Noofdays]/7)+1))
It says the expression has wrong number of arguments
I have tried for hours and I NEED HELPP!!!
Thank you,Virginia


Reply from Alex Hedley:

=IIF( Expression, TruePart, FalsePart )

IIf(
  [Noofdays]<=8,
  1,
  IIf(
    Int(
      ([Noofdays]/7)=([Noofdays]/7)
    ),
   ([Noofdays]/7)
  MISSING
  ),Int(([Noofdays]/7)+1))


Tip
Glossary
Show Just This Thread        Post Reply
Read Cant get IIF function to work correctly by simon B @ 2/4/2016
Your code appears to read in sudotext,
if the cellphone is null then return the phone
if the phone is null then return the cellphone

if you code gets to the second condition you will be trying to return a null value which will most likely throw the system into a fit.

the last part checking to see if both cellphone and phone is null is not required as you can only get to this part if both are null anyway so just return "Missing Number"

Also are Cellphone and Phone numbers or text fields, if they are number fields then trying to return "Missing Number" would cause you a problem as you would be
returning a string when you need to be returning a number
Show Just This Thread        Post Reply
Read Cant get IIF function to work correctly by Rami Jebara @ 1/30/2016
iif([Cellphone] is null , [Phone],iif([Phone] is null,[Cellphone],iff([CellPhone] and [Phone] is null,"Missing Number"," ")))

Just Copy and Paste This Expression i'm Sure it Will Work..
Show Just This Thread        Post Reply
Read Cant get IIF function to work correctly by luyonjo stephen @ 1/29/2016
You seem to have typed "IFF" rather than "IIF". Could that be the cause?
Show Just This Thread        Post Reply
Read Cant get IIF function to work correctly by Bonnie @ 1/28/2016
This may be too simple an answer!  I have had problems with errors on a IIF statement because I had forgotten the equal sign (=)! Bonnie
Show Just This Thread        Post Reply
Read Cant get IIF function to work correctly by David Spens @ 1/28/2016
You seem to be trying to present three alternatives so you will need nested IIFs. IIF(condition is true, result 1, IIF (other condition is true, result 2, result 3)). Try nesting the IIFs
Show Just This Thread        Post Reply
Read Cant get IIF function to work correctly by janne @ 1/28/2016
Hey.

I have been trying to get this IIF function to work correctly for what i want it to do. But i keep on getting this error message when doing it "The expressions syntax is unvalid" (dont know if my transslation was 100% correct there about the error message).

The thing i want to do is this:
I have a feild called phone and one for cellphone and i want the IIF function to show the cellphone nr first. If it doesnt have a cellphone nr in it I want it to show the phone nr instead. And if i doesnt have a cellphone or a ordinary phone to give me a message "Missing number".

I have tried to use this:

Contakt: IIF(IsNull([Cellphone]),[Phone],"Missing Number")

But that doesnt work. So i tried this:

Contakt: IFF(IsNull([Cellphone]),[Phone],[Cellphone])

But that doesnt work either. Have tried Moore things but nothing can make the IIF function to get anything other than the syntax error message. What am  doing wrong and how should i do this IIF function to make it work?


Reply from Alex Hedley:

IIF Function (Glossary)
=IIF(Condition, Value If True, Value If False)

What is your outcome for 'Contakt', does it show any value?

Checks:
Len(Nz(Me.controlname, "")) = 0
len(string) < 1
string = ""
Show Just This Thread        Post Reply
Read Access Query - IIF Function by Kurt Johnston @ 11/1/2014
I have the following in a query:
SELECT [Auction transactions].[SellerID], [Auction transactions].[ItemNumber], [Auction transactions].[Price], [Auction transactions].[BuyerID], [Price]*0.70 AS SellerShare, [Price]*0.30 AS HCCSHare
FROM [Auction transactions]
WHERE [Auction transactions].[SellerID]=[Seller ID];

It functions quite well but we need it to do something a little different.  If the Price is < or = 2.00 then we need the 0.70 to be 0.00 and the 0.30 to be 1.00.  I was thinking using iif but could not figure out how.  Any help is appreciated


Reply from Alex Hedley:

Hi Kurt,
Rich covers the IIF Function in Access Expert Level 8
Show Just This Thread        Post Reply
Read IIF Function Help by Keith P @ 4/2/2014
Thanks a million.  I will try that.
Show Just This Thread        Post Reply
Read IIF Function Help by Keith P @ 4/1/2014
Please HELP!!  I am trying to write an "IIF" statement to assign grades, but my syntax keeps coming up bad.  I have the following:
=IIf([FinalGradeScore] >=90, "A", IIF([FinalGradeScore] >=80 and <90, "B", IIF([FinalGradeScore] >=70 and <80, "C", IIF([FinalGradeScore] >=60 and <70, "D", "F"))))


Reply from Richard Rost:

You can't use AND in the IIF function like that, and you don't even need it. Try:

=IIf([FinalGradeScore]>=90, "A", IIF([FinalGradeScore]>=80, "B", IIF([FinalGradeScore] >=70, "C", IIF([FinalGradeScore] >=60, "D", "F"))))

If the grade is 90 or higher, the first condition is used. If that's NOT true, the second condition checks if the value is then over 80, and so on...
Show Just This Thread        Post Reply

Collapse All Topics

 

Post Your Comments or Subscribe
    If you would like to be notified of new posts on this forum,
    just enter your email address below. It will be kept private.
 
If you just want to subscribe to get email updates when this forum is updated, then enter your name and email address and check the Notify Me box below. If you would optionally like to add your comments below to be posted, they are welcome.
 
  Your Name:  Required
  Your Email:  NOT Public
  Subject:
  Comments:

 

Sorry about this step. It's just to keep the spam bots away:
  Verify: What is 4+2:
  
  Notify me when the this forum is updated
  Remember Me for my next comments
  
 
 
Please do not use this form for Customer Service inquiries! If you have questions about your account, shipping info, courses you've ordered, need passwords, etc. please use the Customer Service Center instead.

I value your comments. They will be displayed on this page (above). Your name will be displayed, but your email address will not be.
As always, I promise to never give away your personal information to anyone else, ever.

NOTE: If you don't leave your name and email address, DON'T expect a reply. I can't promise a personal reply to everyone who posts here. I TRY my best, but I cannot guarantee it. If you don't leave your real name and email address, I won't even bother. I usually just hit DELETE. -Richard

 

 

You may want to read these articles from the 599CD News:

7/19/2017Access Developer 2 and 3 Released
7/19/2017Microsoft Access Developer 3
7/19/2017Microsoft Access Developer 2
6/30/2017Access Developer 2 is Finished
6/7/2017Microsoft Access Developer 1
6/6/2017Access Developer 1 is Finished
5/18/2017Microsoft Access Advanced 6
5/17/2017Access Advanced 6 is Online
4/9/2017Microsoft Access Advanced 5
4/9/2017Microsoft Access Advanced 4
 

Learn
 
Accessindex
Excelindex
Wordindex
Windowsindex
PowerPointindex
Photoshopindex
Visual Basicindex
ASPindex
Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
Free Upgrades
Insider Circle
Student Databases
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Articles
Search Our Site
Waiting List
Production Schedule
Collapse Menus
Help
 
Live Chat
Customer Support
WalkThru Tutorials
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order
 
Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Gift CDs
Contact
 
Live Chat
General Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Facebook    Twitter

Google Plus    LinkedIn

Blog RSS Feed    YouTube Channel
Richard Rost Microsoft MVP