Connecting Tech Pros Worldwide Help | Site Map

Help with nested IIF statement in a query

  #1  
Old August 10th, 2006, 02:05 PM
BerkshireGuy
Guest
 
Posts: n/a
Hello all.

This expression is in my query and it works well. However, if both
continues are false, I want it to say "Not Yet Issued". I've added
that and getting an #ERROR.

Any ideas?

TimeToIssue: IIf(Not
IsNull([ApprovedStandardTransDate]),DateDiff("d",[REceivedTransdate],[ApprovedStandardTransDate]),IIf(Not
IsNull([ApprovedSubStandardTransDate]),DateDiff("d",[REceivedTransdate],[ApprovedSubStandardTransDate]),"Not
Yet Approved"))

  #2  
Old August 10th, 2006, 02:35 PM
BerkshireGuy
Guest
 
Posts: n/a

re: Help with nested IIF statement in a query


Please also make note that:

TimeToIssue: IIf(Not
IsNull([ApprovedStandardTransDate]),DateDiff("d",[ReceivedTransdate],[ApprovedStandardTransDate]),"TEST")


works

And

TimeToIssue: IIf(Not
IsNull([ApprovedSubStandardTransDate]),DateDiff("d",[ReceivedTransdate],[Approved
SubStandardTransDate]),"TEST")

works

It's only when I try to nest them I get the #Error


BerkshireGuy wrote:
Quote:
Hello all.
>
This expression is in my query and it works well. However, if both
continues are false, I want it to say "Not Yet Issued". I've added
that and getting an #ERROR.
>
Any ideas?
>
TimeToIssue: IIf(Not
IsNull([ApprovedStandardTransDate]),DateDiff("d",[REceivedTransdate],[ApprovedStandardTransDate]),IIf(Not
IsNull([ApprovedSubStandardTransDate]),DateDiff("d",[REceivedTransdate],[ApprovedSubStandardTransDate]),"Not
Yet Approved"))
  #3  
Old August 10th, 2006, 02:35 PM
Allen Browne
Guest
 
Posts: n/a

re: Help with nested IIF statement in a query


What data type do you want the TimeToIssue to be?

If you want to treat it like a number, then assigning text like "Not Yet
Approved" is going to foul it up. Better to leave it as Null, and then put
that into the text box where it will be displayed. For that result, try:
TimeToIssue: DateDiff("d",[REceivedTransdate],
Nz([ApprovedStandardTransDate], [ApprovedSubStandardTransDate])

If you don't care that is is treated as text (e.g. 2 sorts after 10), try:
TimeToIssue: Nz(DateDiff("d",[REceivedTransdate],
Nz([ApprovedStandardTransDate], [ApprovedSubStandardTransDate]), "Not Yet
Approved")

--
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.

"BerkshireGuy" <bdaoust@yahoo.comwrote in message
news:1155215241.112134.280440@m79g2000cwm.googlegr oups.com...
Quote:
Hello all.
>
This expression is in my query and it works well. However, if both
continues are false, I want it to say "Not Yet Issued". I've added
that and getting an #ERROR.
>
Any ideas?
>
TimeToIssue: IIf(Not
IsNull([ApprovedStandardTransDate]),DateDiff("d",[REceivedTransdate],[ApprovedStandardTransDate]),IIf(Not
IsNull([ApprovedSubStandardTransDate]),DateDiff("d",[REceivedTransdate],[ApprovedSubStandardTransDate]),"Not
Yet Approved"))

  #4  
Old August 10th, 2006, 02:45 PM
BerkshireGuy
Guest
 
Posts: n/a

re: Help with nested IIF statement in a query


Allen,

Thank you. I tried your suggestion and it work. I appreciate your
quick response.

Have a great day,
Brian



Allen Browne wrote:
Quote:
What data type do you want the TimeToIssue to be?
>
If you want to treat it like a number, then assigning text like "Not Yet
Approved" is going to foul it up. Better to leave it as Null, and then put
that into the text box where it will be displayed. For that result, try:
TimeToIssue: DateDiff("d",[REceivedTransdate],
Nz([ApprovedStandardTransDate], [ApprovedSubStandardTransDate])
>
If you don't care that is is treated as text (e.g. 2 sorts after 10), try:
TimeToIssue: Nz(DateDiff("d",[REceivedTransdate],
Nz([ApprovedStandardTransDate], [ApprovedSubStandardTransDate]), "Not Yet
Approved")
>
--
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.
>
"BerkshireGuy" <bdaoust@yahoo.comwrote in message
news:1155215241.112134.280440@m79g2000cwm.googlegr oups.com...
Quote:
Hello all.

This expression is in my query and it works well. However, if both
continues are false, I want it to say "Not Yet Issued". I've added
that and getting an #ERROR.

Any ideas?

TimeToIssue: IIf(Not
IsNull([ApprovedStandardTransDate]),DateDiff("d",[REceivedTransdate],[ApprovedStandardTransDate]),IIf(Not
IsNull([ApprovedSubStandardTransDate]),DateDiff("d",[REceivedTransdate],[ApprovedSubStandardTransDate]),"Not
Yet Approved"))
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
IIf in query won't return false KiwiGenie answers 4 March 7th, 2007 12:25 AM
Query criteria for Filtering Date fields: IIF Nested Operators won't work Ragbrai answers 8 December 30th, 2006 10:16 PM
query to increment record numbers Noah answers 4 June 18th, 2006 08:25 PM
SQL Problem JMorrell answers 10 July 21st, 2005 09:44 PM