I am using access 2003. I am trying to calculate a report period based on todays date. My code works for todays date but when I was testing for other dates less than 10 that is when I run into problems. I have attempted a couple of solutions with no luck. This code works but if I change the date to 3/6/2012 that is when I get the error. Any help is appreciated.
Code:
Public Function CurRptMon(pd As Integer)
Dim strCurDate As Date
Dim strCurMon As String
Dim iCurYr As Integer
Dim iCurMon As Integer
Dim iCurPd As Integer
Dim iCurMonPd As Integer
Dim ipdCalc As Integer
strCurDate = #11/6/2013#
iCurYr = CInt(Right(strCurDate, 4))
iCurMon = CInt(Left(strCurDate, 2))
If iCurMon = 0 Then
iCurMon = CInt(Left(strCurDate, 1))
Else
iCurMon = CInt(Left(strCurDate, 2))
End If
iCurMonPd = iCurMon - 1
If iCurMonPd = 1 Then strCurMon = "Jan"
If iCurMonPd = 2 Then strCurMon = "Feb"
If iCurMonPd = 3 Then strCurMon = "Mar"
If iCurMonPd = 4 Then strCurMon = "Apr"
If iCurMonPd = 5 Then strCurMon = "May"
If iCurMonPd = 6 Then strCurMon = "Jun"
If iCurMonPd = 7 Then strCurMon = "Jul"
If iCurMonPd = 8 Then strCurMon = "Aug"
If iCurMonPd = 9 Then strCurMon = "Sep"
If iCurMonPd = 10 Then strCurMon = "Oct"
If iCurMonPd = 11 Then strCurMon = "Nov"
If iCurMonPd = 12 Then strCurMon = "Dec"
ipdCalc = 360
If iCurYr = 2013 Then ipdCalc = ipdCalc + 11
If iCurYr = 2014 Then ipdCalc = ipdCalc + 21
If iCurYr = 2015 Then ipdCalc = ipdCalc + 31
If iCurYr = 2016 Then ipdCalc = ipdCalc + 41
pd = ipdCalc + iCurMonPd
End Function