Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Queries

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 05-17-2010, 09:43 PM
bdhFS bdhFS is offline Windows XP Access 2007 (version 12.0)
Novice
 
Join Date: May 2010
Posts: 4
bdhFS is on a distinguished road
Default IIf Statement...HELP!

I am trying to query a couple of fields to base the final output. Here is what I have so far, but it is just not working...can someone please help me.

IIf(IsNull([Num_Files] And [Failed_YN]="N","0",IIf(IsNull([Num_Files] And [Failed_YN]="Y",".",[Num_Files]))))


So, I have a field called "Num_Files" in a table, and "Failed_YN" in another table and the two tables are linked by a key field. If the unit did not fail (N), and the Num_Files is null, then I want it to put a zero. If the unit did fail (Y), and the Num_Files is null, then I want it to put a period. Else, keep the value in the Num_Files field.
THANKS SO MUCH!
Reply With Quote
  #2  
Old 05-17-2010, 09:50 PM
pbaldy's Avatar
pbaldy pbaldy is online now Windows XP Access 2007 (version 12.0)
Who is John Galt?
 
Join Date: Feb 2010
Location: Nevada, USA
Posts: 1,499
pbaldy is on a distinguished road
Default

For starters, you need to close off the IsNull function:

IIf(IsNull([Num_Files]) And [Failed_YN]="N",...

Is Failed_YN a text field? That's how you're treating it. If it's a Yes/No field:

And [Failed_YN]=False

or

And [Failed_YN]=0
__________________
Paul
MS Access MVP
www.BaldyWeb.com
Reply With Quote
  #3  
Old 05-18-2010, 09:30 AM
bdhFS bdhFS is offline Windows XP Access 2007 (version 12.0)
Novice
 
Join Date: May 2010
Posts: 4
bdhFS is on a distinguished road
Default Got it to work

Thank you so much for your reply Paul. That is exactly what I was missing...")" and it is working.

I was curious...is there a difference or preferance in doing it this way instead...instread of using the IsNull Function?

IIf([Num_Files] is null And [Failed_YN]="N"
Reply With Quote
  #4  
Old 05-18-2010, 09:34 AM
pbaldy's Avatar
pbaldy pbaldy is online now Windows XP Access 2007 (version 12.0)
Who is John Galt?
 
Join Date: Feb 2010
Location: Nevada, USA
Posts: 1,499
pbaldy is on a distinguished road
Default

Happy to help. I'm not sure there would be any performance difference either way. I'd use whichever one you're more comfortable with.

Welcome to the site by the way!
__________________
Paul
MS Access MVP
www.BaldyWeb.com
Reply With Quote
  #5  
Old 05-18-2010, 09:50 AM
bdhFS bdhFS is offline Windows XP Access 2007 (version 12.0)
Novice
 
Join Date: May 2010
Posts: 4
bdhFS is on a distinguished road
Default Thankful!

I am so thankful for people like you...who help people like me! I am greatful for resources like this that help me get my work done! I am sure I will be back over and over again!
Reply With Quote
  #6  
Old 05-19-2010, 05:55 AM
CGM3 CGM3 is offline Windows XP Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Sep 2009
Location: Atlanta, GA
Posts: 36
CGM3 is on a distinguished road
Default

Just a suggestion, I'd go with:

IIf(IsNull([Num_Files]), IIf([Failed_YN]="Y", ".", "0"), [Num_Files])

In the original format, if [Num_Files] was null and [Failed_YN] happened to be anything other than "Y" or "N", the formula would have bombed when it tried to apply the (null) [Num_Files]. This way, if [Num_Files] is null, you return "." if [Failed_YN] is "Y" and "0" otherwise.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If statement for image turbo910 Forms 1 11-30-2009 01:58 AM
If statement Issue???? graviz Programming 1 09-25-2009 08:09 AM
IIF statement james1982 Access 1 07-20-2009 07:38 AM
how to use IF then statement ronnie4 Access 1 03-17-2009 09:32 PM
multiple iif statement NEED HELP PLZ scott munkirs Reports 1 09-27-2006 03:21 AM


All times are GMT -8. The time now is 10:14 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.