Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,520 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,941 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
post 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

Go to the top of the page


jjsaw5
post 9 Oct, 2008 - 04:02 AM
Post #2


I vill break you

Group Icon
Joined: 4 Jan, 2008
Posts: 1,340



Thanked 6 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

Go to the top of the page

AdaHacker
post 9 Oct, 2008 - 06:28 AM
Post #3


D.I.C Head

**
Joined: 17 Jun, 2008
Posts: 162



Thanked 23 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

Go to the top of the page

slh
post 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

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 01:04AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month