Welcome to Dream.In.Code
Become an Expert!

Join 137,384 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,126 people online right now. Registration is fast and FREE... Join Now!




Nested IF Question

 
Reply to this topicStart new topic

Nested IF Question, MS Access

slh
8 Oct, 2008 - 01:46 PM
Post #1

New D.I.C Head
*

Joined: 8 Oct, 2008
Posts: 3

Hello all,
I have a Microsoft Access database that prints continuing education certificates after employee has completed required hours. The certificate prints the day the employee was issued(date of issuance) the certificate. The code works most of the time but when you try to print out a batch of certificates it will print "this the 12nd day of August 2008". It puts the "nd" where "th" should be. Could someone please advise what I am doing wrong.
Thanks in advance. My code is below. I am a newbie and lost........

Thanks,
Sherry


CODE
=IIf(Not IsNull([Date of Issuance for CCMP-II]),"in the state mental health system , this the " & Format([Date of Issuance for CCMP-II],"d") & IIf(Right(Format([Date of Issuance for CCMP-II],"dd"),2)=11,"th",IIf(Right(Format([Date of Issuance for CCMP-II],"dd"),1)=1,"st",IIf(Right(Format([Date of Issuance for CCMP-II],"dd"),1)=2,"nd",IIf(Right(Format([Date of Issuance for CCMP-II],"dd"),1)=3,"rd","th")))) & " day of " & Format([Date of Issuance for CCMP-II],"mmmm") & ", " & Format([Date of Issuance for CCMP-II],"yyyy") & ".",IIf(Not IsNull([Date of Issuance for CCMP-I]),"in the state mental health system, this the " & Format([Date of Issuance for CCMP-I],"d") & IIf(Right(Format([Date of Issuance for CCMP-I],"dd"),2)=11,"th",IIf(Right(Format([Date of Issuance for CCMP-I],"dd"),1)=1,"st",IIf(Right(Format([Date of Issuance for CCMP-I],"dd"),1)=2,"nd",IIf(Right(Format([Date of Issuance for CCMP-I],"dd"),1)=3,"rd","th")))) & " day of " & Format([Date of Issuance for CCMP-I],"mmmm") & ", " & Format([Date of Issuance for CCMP-I],"yyyy") & ".","None"))

User is offlineProfile CardPM
+Quote Post

jjsaw5
RE: Nested IF Question
9 Oct, 2008 - 04:02 AM
Post #2

I must break you
Group Icon

Joined: 4 Jan, 2008
Posts: 1,411



Thanked: 7 times
Dream Kudos: 125
Expert In: HTML, CSS, Database,

My Contributions
Please make sure you are using descriptive thread titles. "Need Help" is not a good title.



Changed title.
User is offlineProfile CardPM
+Quote Post

AdaHacker
RE: Nested IF Question
9 Oct, 2008 - 06:28 AM
Post #3

D.I.C Head
**

Joined: 17 Jun, 2008
Posts: 178



Thanked: 28 times
My Contributions
That's because you have a case in your painfully long Iif() is returning "nd" if the last character of the day is 2. You need to either nunance it to check the entire day instead of the last character, or just add an exception for 12 like you did for 11.
User is offlineProfile CardPM
+Quote Post

slh
RE: Nested IF Question
9 Oct, 2008 - 08:15 AM
Post #4

New D.I.C Head
*

Joined: 8 Oct, 2008
Posts: 3

QUOTE(AdaHacker @ 9 Oct, 2008 - 07:28 AM) *

That's because you have a case in your painfully long Iif() is returning "nd" if the last character of the day is 2. You need to either nunance it to check the entire day instead of the last character, or just add an exception for 12 like you did for 11.



Thank you AdaHacker, I added the exception for 12 and it worked. I know this is a long(and hard to read) nested iif but I am just getting started and it was the only way I knew how to make it print what I needed. I am learning VB, I usderstand that would have been a better way to write the code. Thank you for your help !!!!!!!

Thanks,
SLH
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/5/08 02:03AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month