G
Guest
The following code works perfectly for a report that creates an ASCII file.
The problem centers on the last month of the year (December) and the first
month of the year (January). The ASCII file display the year 2003 for
January (when it should be the current year) and the month 0228 for January
(when it should be 131). Here's the code. Any help will be appreciated:
Private Function LastDayOfMonth() As String
ActForm = Me.Name
FuncName = "LastDayOfMonth"
SectNum = 1
On Error GoTo LastDayOfMonth_Err
Dim dDate As Date
Dim sDate1 As String
sDate1 = "01" & "/" & Format([txtdtEnd].Value + 30, "MMM") & "/" &
Year([txtdtEnd].Value)
dDate = CDate(sDate1) - 1
LastDayOfMonth = Format(dDate, "YYYYMMDD")
LastDayOfMonth_Exit:
Exit Function
LastDayOfMonth_Err:
iENum = Err
EMsg = Error
ret = Add2ErrorLog(iENum, EMsg, FuncName, SectNum, ActForm)
ret = ErrorMessage(iENum, EMsg, FuncName, SectNum, ActForm)
Resume Next
End Function
The problem centers on the last month of the year (December) and the first
month of the year (January). The ASCII file display the year 2003 for
January (when it should be the current year) and the month 0228 for January
(when it should be 131). Here's the code. Any help will be appreciated:
Private Function LastDayOfMonth() As String
ActForm = Me.Name
FuncName = "LastDayOfMonth"
SectNum = 1
On Error GoTo LastDayOfMonth_Err
Dim dDate As Date
Dim sDate1 As String
sDate1 = "01" & "/" & Format([txtdtEnd].Value + 30, "MMM") & "/" &
Year([txtdtEnd].Value)
dDate = CDate(sDate1) - 1
LastDayOfMonth = Format(dDate, "YYYYMMDD")
LastDayOfMonth_Exit:
Exit Function
LastDayOfMonth_Err:
iENum = Err
EMsg = Error
ret = Add2ErrorLog(iENum, EMsg, FuncName, SectNum, ActForm)
ret = ErrorMessage(iENum, EMsg, FuncName, SectNum, ActForm)
Resume Next
End Function