I'm a beginner (at best) to writing code. I have a "Completion_Date" field in my form. However my work months are not based on calendar months, so I want to populate another field with the work month based on the date that was entered in the Completion_Date.
I'm using Access 2003. Can anyone tell me why the following code doesn't work?
Public Function DateBucket(Completion_Date As Date) As String
Select Case Completion_Date
Case Is <= #12/20/2007#
DateBucket = "Prior_Year - " & Completion_Date
Case Is <= #1/25/2008# And Completion_Date >= #12/21/2007#
DateBucket = "January 2008"
Case Is <= #2/22/2008# And Completion_Date >= #1/26/2008#
DateBucket = "February 2008"
Case Is <= #3/21/2008# And Completion_Date >= #2/23/2008#
DateBucket = "March 2008"
Case Is <= #4/25/2008# And Completion_Date >= #3/22/2008#
DateBucket = "April 2008"
Case Is <= #5/23/2008# And Completion_Date >= #4/26/2008#
DateBucket = "May 2008"
Case Is <= #6/20/2008# And Completion_Date >= #5/24/2008#
DateBucket = "June 2008"
Case Is <= #7/25/2008# And Completion_Date >= #6/21/2008#
DateBucket = "July 2008"
Case Is <= #8/22/2008# And Completion_Date >= #7/26/2008#
DateBucket = "August 2008"
Case Is <= #9/19/2008# And Completion_Date >= #8/23/2008#
DateBucket = "September 2008"
Case Is <= #10/24/2008# And Completion_Date >= #9/20/2008#
DateBucket = "October 2008"
Case Is <= #11/21/2008# And Completion_Date >= #10/25/2008#
DateBucket = "November 2008"
Case Is <= #12/26/2008# And Completion_Date >= #11/22/2008#
DateBucket = "December 2008"
Case Else
DateBucket = "Future_Year - " & Completion_Date
End Select
End Function
Thanks in advance!
I'm using Access 2003. Can anyone tell me why the following code doesn't work?
Public Function DateBucket(Completion_Date As Date) As String
Select Case Completion_Date
Case Is <= #12/20/2007#
DateBucket = "Prior_Year - " & Completion_Date
Case Is <= #1/25/2008# And Completion_Date >= #12/21/2007#
DateBucket = "January 2008"
Case Is <= #2/22/2008# And Completion_Date >= #1/26/2008#
DateBucket = "February 2008"
Case Is <= #3/21/2008# And Completion_Date >= #2/23/2008#
DateBucket = "March 2008"
Case Is <= #4/25/2008# And Completion_Date >= #3/22/2008#
DateBucket = "April 2008"
Case Is <= #5/23/2008# And Completion_Date >= #4/26/2008#
DateBucket = "May 2008"
Case Is <= #6/20/2008# And Completion_Date >= #5/24/2008#
DateBucket = "June 2008"
Case Is <= #7/25/2008# And Completion_Date >= #6/21/2008#
DateBucket = "July 2008"
Case Is <= #8/22/2008# And Completion_Date >= #7/26/2008#
DateBucket = "August 2008"
Case Is <= #9/19/2008# And Completion_Date >= #8/23/2008#
DateBucket = "September 2008"
Case Is <= #10/24/2008# And Completion_Date >= #9/20/2008#
DateBucket = "October 2008"
Case Is <= #11/21/2008# And Completion_Date >= #10/25/2008#
DateBucket = "November 2008"
Case Is <= #12/26/2008# And Completion_Date >= #11/22/2008#
DateBucket = "December 2008"
Case Else
DateBucket = "Future_Year - " & Completion_Date
End Select
End Function
Thanks in advance!