Function DailyMonthTracking()
'This will test daily the CurrentMonth against the PreviousMonth.
'Upon the start of a new month the table will be adjusted to reflect the
'correct CurrentMonth and PreviousMonth.
Dim sCurrentMonth As String
Dim sPreviousMonth As String
Dim rCurrentMonth As Object
Dim rPreviousMonth As Object
Dim dbDatabase As Object
Set dbDatabase = CurrentDb
Set rCurrentMonth = dbDatabase.OpenRecordset("ReportDate")
Set rPreviousMonth = dbDatabase.OpenRecordset("ReportDate")
sCurrentMonth = Format(Now(), "mmm")
'Check to see if CurrentMonth has changed each day, if no change exit
If rCurrentMonth("CurrentMonth") = sCurrentMonth Then
GoTo EndDailyMonthTracking
Else
'If change, adjust table and exit
rPreviousMonth.Edit
rPreviousMonth("PreviousMonth").Value = rCurrentMonth("CurrentMonth")
rPreviousMonth.Update
rCurrentMonth.Edit
rCurrentMonth("CurrentMonth").Value = sCurrentMonth
rCurrentMonth.Update
GoTo EndDailyMonthTracking
End If
EndDailyMonthTracking:
End Function